<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ErrorOK &#187; Software Developement</title>
	<atom:link href="http://blog.errorok.com/category/dev/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.errorok.com</link>
	<description>A library of useless knowledge</description>
	<lastBuildDate>Wed, 28 Dec 2011 19:31:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Simplifying Complicated SQL queries in LINQ</title>
		<link>http://blog.errorok.com/2011/12/01/243/</link>
		<comments>http://blog.errorok.com/2011/12/01/243/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 20:12:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software Developement]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[linq]]></category>

		<guid isPermaLink="false">http://blog.errorok.com/?p=243</guid>
		<description><![CDATA[quick how to on using group by with aggregate function columns in LINQ.]]></description>
			<content:encoded><![CDATA[<p>I have been working pretty heavily in LINQ the past few days and ran into a few problems when dealing with some more complicated queries.  While LINQ is fairly simple and intuitive when working with objects in memory, the LINQ-SQL bridge (or SQLite in my case) is a different machine.  The reason it is different is that your queries must be translated into the appropriate SQL, and this SQL can sometimes turn into brutally inefficient queries.</p>
<p>In my case i was working on a query that inner joined three tables together, then grouped by one of the columns in the joined tables.  Now LINQ can do this no problem with Join/Join/GroupBy.  The difficulty lies in how you project your grouped columns. By default LINQ will just include the whole collection of grouped columns per group row.  While this works great in memory, the SQL bridge butchers your call.  The reason is that SQL (SQLite at least) can&#8217;t do what you asked so the translation is to group by, then do a select all for each group row.  As you can imagine, the computational power required grows exponentially with the data size.  This is quite clearly very bad.</p>
<p>When working in pure SQL, we can only include columns that are in the group key and columns with an aggregation function applied to them.  The aggregation functions are not super obvious on how to use them, so this is what i will be simplifying in this post.  Usually what you want is the Sum, Count, First Row, Last Row, etc&#8230; from your grouped rows.  The main problem is that you can&#8217;t just call the LINQ aggregate functions normally, because it doesn&#8217;t make sense in the context of your group by projection.  I&#8217;ll start off with some sample code and move on from there explaining as i go.</p>
<p>First we join the tables together, and project the join into an anonymous type with both values<br />
<code>var q1 = Table1.Join(Table2, x => x.t2key, x => x.key, (t1, t2) => new { t1, t2 })</code></p>
<p>Now we can group by (say by t1) so that we end up with t1, and an enumerable of t2&#8217;s.<br />
<code>var q2 = q1.GroupBy(x => x.t1.key, x => x.t2, (k, x) => new { k.Name, Timestamp = x.Max(y => y.Timestamp), Value = x.Max(y => y.Value) })</code><br />
so the first lambda tells us what to group on (our parent key), the second lambda describes how to project the grouped data (we will just project the whole t2 table), and the third lambda describes how to project the result set.  The third lambda is where things get interesting, we can include members of the key as is (k.Name), but for members of the grouped data, we must apply the aggregate functions or risk a horribly inefficient query.  In the above example, i am using the Max aggregate function, which (in SQLite land at least, but others as well im sure) will select the last item in the group as determined by the order by clause (which i didn&#8217;t include).  Because i didn&#8217;t include an order by then its just the last item in the grouped data however the grouped data was built.  The order by must appear before the group by in order for it to affect the aggregation functions, so above i would do something like <code>q1 = q1.OrderBy(x => x.t2.Timestamp)</code> in order for the Max function to return the most recent value in the grouped data.  If you specify an order by after the group by, it will order the projected group results, so you could do something like <code>q2 = q2.OrderBy(x => x.Value)</code> in order to show the values in ascending order, without affecting the group by aggregation.  This is executed by a wrapper query, that uses the projected grouped data as input, so you execute a second query, but that&#8217;s it (and this one is generally quite fast)</p>
<p>So the important bits to take a way from this post is that any aggregated columns you want to project must be individually included in your group by result projection, and if you include any enumerations in your projection then they will be converted into subqueries.  While my example may not be all that complicated, it is certainly more complicated than simple a select/join/where/order type of LINQ query, which are far more common.  By understanding the group by projection core concepts, it should be relatively easy to construct much more complicated (AND efficient) LINQ queries.  And remember, when in doubt play around in LINQPad, that program is the best for testing out LINQ queries.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.errorok.com/2011/12/01/243/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some alternative Zip extension methods</title>
		<link>http://blog.errorok.com/2011/08/22/237/</link>
		<comments>http://blog.errorok.com/2011/08/22/237/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 00:07:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software Developement]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[linq]]></category>
		<category><![CDATA[zip]]></category>

		<guid isPermaLink="false">http://blog.errorok.com/?p=237</guid>
		<description><![CDATA[Using Linq's Zip with multiple arrays (enumerables)]]></description>
			<content:encoded><![CDATA[<p>I ran into a small problem today, i had &#8216;n&#8217; arrays of correlated data.  I wanted to effectively &#8220;transpose&#8221; the rows into columns so that i would end up with the same number of arrays but containing the items of the same index of all arrays. to simplify that terrible explanation, here are some visuals:</p>
<p>start : [a0, a1, a2], [b0, b1, b2], [c0, c1, c2] &#8211;&gt; transpose &#8211;&gt; [a0, b0, c0], [a1, b1, c1], [a2, b2, c2]</p>
<p>Now the Zip function in .net4 can do this very easily, but only for TWO enumerables, not any number.  Its basic function is to interleave two enumerables and project the result. I wanted to do something similar but without the silly two enumerable limitation.  It&#8217;s very easy to extend Zip to operate on &gt; 2 enumerables statically, you just need to add more and more params to the extension method, but i wanted to have true dynamic interleaving functionality.  So i wrote two extension methods (really just one, and then a simplification for the standard projection) that would do this.  One consequence to note is that this will be slower than the built-in Zip, quite obviously because we&#8217;re dealing with more enumerables, but also because we can&#8217;t run the same type of optimizations that Zip does (this is due to the dynamic nature of this function).  So here is some code to look at:</p>
<pre>public static IEnumerable&lt;TResult&gt; ZipMany&lt;TItem, TResult&gt;(
    this IEnumerable&lt;IEnumerable&lt;TItem&gt;&gt; source,
    Func&lt;IEnumerable&lt;TItem&gt;, TResult&gt; func)
{
    var iters = source.Select(x =&gt; x.GetEnumerator()).ToArray();
    while (iters.All(x =&gt; x.MoveNext()))
    {
        yield return func(iters.Select(x =&gt; x.Current));
    }
}

public static IEnumerable&lt;List&lt;TItem&gt;&gt; ZipMany&lt;TItem&gt;(
    this IEnumerable&lt;IEnumerable&lt;TItem&gt;&gt; source)
{
    return ZipMany(source, x =&gt; x.ToList());
}</pre>
<p>So the idea is we build an array of enumerators for each of the input source lists.  We have to call ToArray to invoke the execution of the projection, otherwise some strange and undesirable stuff happens.  Then we just iterate each enumerator at the same pace and project the index aligned projection of the results.  It&#8217;s actually pretty simple code for what it is really doing, but it works quite well and i thought i would share it.  The second method is just a helper that simplifies the first by removing the need to project the results, this way you can project the results into any custom type if you want, but the default is to simply project them into a list (which is how i can imaging myself and most others wanting the results returned).</p>
<p>I am curious if anyone can point out any improvements or optimizations on this code.  Mostly just so i can learn from them myself.  Other than that, i am quite happy with how this turned out and it works wonderfully with the application that i wanted to use it with.</p>
<p>This same post is available at the msdn forums if you want to follow the comments there as well: <a href="http://social.msdn.microsoft.com/Forums/eu/linqprojectgeneral/thread/40cc2410-adad-4da6-80cd-1736140e885e">http://social.msdn.microsoft.com/Forums/eu/linqprojectgeneral/thread/40cc2410-adad-4da6-80cd-1736140e885e</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.errorok.com/2011/08/22/237/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Bitcoin Email Alerts on Mt. Gox Price Changes</title>
		<link>http://blog.errorok.com/2011/07/21/234/</link>
		<comments>http://blog.errorok.com/2011/07/21/234/#comments</comments>
		<pubDate>Thu, 21 Jul 2011 16:31:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software Developement]]></category>
		<category><![CDATA[bitcoin]]></category>

		<guid isPermaLink="false">http://blog.errorok.com/?p=234</guid>
		<description><![CDATA[configurable email price alerts for price changes on the Mt. Gox exchange.]]></description>
			<content:encoded><![CDATA[<p>I got fed up with watching <a href="http://mtgoxlive.com">mtgoxlive.com</a> all day long so I wrote a simple web service to monitor the Mt. Gox prices for me.  Then I wrote a simple engine to send out email alerts when the price (or volume) goes above or below a specified threshold. The result is <a href="http://btcalerts.errorok.com/">http://btcalerts.errorok.com/</a> which now just tells me when I should pay attention to the exchange, or when my open orders have likely been filled.  The site is designed to eventually track multiple exchanges, but since I do all my trading on Mt. Gox I have only coded its prices in so far.  The site also lacks any flare, but im not one for flare, but rather sustenance.  Anyways, check it out and let me know if you like it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.errorok.com/2011/07/21/234/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sharing Layout Size Info Between Multiple Grids</title>
		<link>http://blog.errorok.com/2011/01/25/230/</link>
		<comments>http://blog.errorok.com/2011/01/25/230/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 19:11:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software Developement]]></category>
		<category><![CDATA[grid]]></category>
		<category><![CDATA[IsSharedSizeScope]]></category>
		<category><![CDATA[SharedSizeGroup]]></category>
		<category><![CDATA[wpf]]></category>

		<guid isPermaLink="false">http://blog.errorok.com/?p=230</guid>
		<description><![CDATA[The title should probably be enough, but in case it isn&#8217;t I am talking about multiple grids in a single view that need to share row size or column size.  A good example of this would be if you wanted to split grid rows up into groups, then apply each group to an expander, [...]]]></description>
			<content:encoded><![CDATA[<p>The title should probably be enough, but in case it isn&#8217;t I am talking about multiple grids in a single view that need to share row size or column size.  A good example of this would be if you wanted to split grid rows up into groups, then apply each group to an expander, thus allowing you to show and collapse the different groups of rows.  However, when everything is expanded, you still want all your columns to line up.  Well, you can use the <strong>Grid.IsSharedSizeScope</strong> attached property for this.  There are some msdn docs on this <a href="http://msdn.microsoft.com/en-us/library/ms751905.aspx">here</a>, but i found them to be somewhat lacking in detail.  So here is is my idiot proof guide (really just the information left out of the msdn article) on how to share grid layout size info.</p>
<p>The most important thing to note is that you only use the attached property to enable (or disable) a scoped region to share size info within.  This is extremely important to understand because scope is not inherited by children if you override it.  For example, if you were to create a grid within a grid and put the attached property on both grid nodes, the second grid would override the scope of the first, and you would NOT get your shared sizing.  You only ever want to put the attached property ONCE for the ENTIRE scope of shared sizing.</p>
<p>With that out of the way, all you need to do now is give your row or column definitions a unique identifier on the SharedSizeGroup property and then all rows or columns that share the same unique identifier will also share the same hight or width respectively.  You should also note that this only works for explicit or Auto sized rows and columns.  If you specify a star on a shared item, it will default it to Auto.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.errorok.com/2011/01/25/230/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Quick Lesson On Simple Yet Confusing Depedency Property Issue</title>
		<link>http://blog.errorok.com/2010/12/16/228/</link>
		<comments>http://blog.errorok.com/2010/12/16/228/#comments</comments>
		<pubDate>Thu, 16 Dec 2010 19:13:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software Developement]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[depedency property]]></category>
		<category><![CDATA[wpf]]></category>

		<guid isPermaLink="false">http://blog.errorok.com/?p=228</guid>
		<description><![CDATA[This is an issue that I just ran into and was a little confused as to why it was happening, but upon thinking about it for a moment it makes perfect sense.
When you are creating your DP&#8217;s, you have the option of specifying a default (initial) value.  The problem with this value is that [...]]]></description>
			<content:encoded><![CDATA[<p>This is an issue that I just ran into and was a little confused as to why it was happening, but upon thinking about it for a moment it makes perfect sense.</p>
<p>When you are creating your DP&#8217;s, you have the option of specifying a default (initial) value.  The problem with this value is that it is created and stored statically.  So if you are creating a DP for, say, a collection, and you initialize it statically in the DP definition then your collection reference now exists statically.  So regardless of whether or not you create ten instances of your DO, they will all contain the same initial value because they will all point to the same static reference.</p>
<p>So the conclusion to this quick lesson is that you should never initialize your DP&#8217;s with reference types, always perform this step at instantiation to guarantee unique DP values per object instance (unless of course you want to share the reference).  As for value types it doesn&#8217;t matter nearly as much because the value is copied anyways.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.errorok.com/2010/12/16/228/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Anonymous Type Return Value in C# 4.0</title>
		<link>http://blog.errorok.com/2010/12/13/208/</link>
		<comments>http://blog.errorok.com/2010/12/13/208/#comments</comments>
		<pubDate>Mon, 13 Dec 2010 16:59:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software Developement]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://blog.errorok.com/?p=208</guid>
		<description><![CDATA[Ever wanted to return an anonymous type from a method or property, but then find out you can&#8217;t use it because there is no valid return type?  Well I have, and I will explain how to get around this issue.
The solution as you may have guessed is to use dynamic types, which allow you to [...]]]></description>
			<content:encoded><![CDATA[<p>Ever wanted to return an anonymous type from a method or property, but then find out you can&#8217;t use it because there is no valid return type?  Well I have, and I will explain how to get around this issue.</p>
<p>The solution as you may have guessed is to use dynamic types, which allow you to build the type definition at run time and return it.  Since there is no static compilation type checking, it doesn&#8217;t care that you can&#8217;t define the return type of your method or property.  This isn&#8217;t something very common, or even recommended in most situations, but it can come in handy in a pinch.  Here is some totally useless, but good sample code explanation.</p>
<pre>private bool flagValue = false;
private bool isFlagValueSet = false;

private dynamic Flag
{
    get
    {
        return new { Value = flagValue, IsValueSet = isFlagValueSet };
    }
}

public bool Test()
{
    return Flag.IsValueSet ? Flag.Value : false;
}</pre>
<p>All you gotta do is ensure that you reference the Microsoft.CSharp.dll to get access to dynamic types.  You won&#8217;t get any intellisense on the flag variable, but that&#8217;s because the type information is computed at runtime only.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.errorok.com/2010/12/13/208/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simulating Multi-Source One Way Data Bindings</title>
		<link>http://blog.errorok.com/2010/12/13/223/</link>
		<comments>http://blog.errorok.com/2010/12/13/223/#comments</comments>
		<pubDate>Mon, 13 Dec 2010 16:44:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software Developement]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[wpf]]></category>

		<guid isPermaLink="false">http://blog.errorok.com/?p=223</guid>
		<description><![CDATA[The title is a bit of a mouthful, so here is the quick synopsis.  We have one to many controls that drive a single view.  Each control implements the same interface, something that provides the view with its context.  That way regardless of what control is used, the single view updates appropriately.
The problem here is [...]]]></description>
			<content:encoded><![CDATA[<p>The title is a bit of a mouthful, so here is the quick synopsis.  We have one to many controls that drive a single view.  Each control implements the same interface, something that provides the view with its context.  That way regardless of what control is used, the single view updates appropriately.</p>
<p>The problem here is that we need to bind the DP of the view&#8217;s context to multiple sources, something which a standard Binding does not allow.  MultiBinding allows multiple sources, but it would be impossible to know which source was actually &#8220;made active&#8221; most recently, so we could never return the right source accurately (unless we gave context to the sources themselves, which would be poor design).</p>
<p>The solution to this problem is rather simple, we just need to manage that multi-source aspect of the binding manually in the location where the binding is made or where the DP&#8217;s live (this could be the same place if you are doing MVVM).  First create a read only DP that will act as your view driving DP, it can be initialized to null.  Now create a standard event handler function to handle the property changed event for the driving DP on each source.  Hook up the DP value changed events:</p>
<pre>private void ViewContext_PropertyChanged(object sender, EventArgs e)
{
    SetValue(ViewContextPropertyKey, (sender as IViewContextProvider).ViewContext);
}</pre>
<pre>DependencyPropertyDescriptor.FromProperty(Source1ViewModel.ViewContextProperty, typeof(Source1ViewModel))
    .AddValueChanged(m_Source1ViewModel, ViewContext_PropertyChanged);</pre>
<p>In the event handler, we simply update your RO DP and that&#8217;s it!</p>
<p>If the scenario seems a little obscure, think of this situation.  You want to write a file explorer type of view, the explorer will obviously display files and folders in some sort of list or grid.  On the left hand side, you have multiple panels that determine the context of the file explorer.  One panel is your local system, another panel is a local search, another panel is an FTP site, etc&#8230;  All these left side panels can drive your single view through this RO DP pattern.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.errorok.com/2010/12/13/223/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Databinding to &#8220;Object Aggregates&#8221;</title>
		<link>http://blog.errorok.com/2010/11/12/220/</link>
		<comments>http://blog.errorok.com/2010/11/12/220/#comments</comments>
		<pubDate>Fri, 12 Nov 2010 22:45:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software Developement]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[databind]]></category>
		<category><![CDATA[icustomtypedescriptor]]></category>
		<category><![CDATA[objectaggregator]]></category>
		<category><![CDATA[objectaggregatorpropertydescriptor]]></category>
		<category><![CDATA[propertydescriptor]]></category>

		<guid isPermaLink="false">http://blog.errorok.com/?p=220</guid>
		<description><![CDATA[The Problem
We have a list of editable items (maybe displayed in a list view), and we have an item editor that can edit a single item.  We want to make our editor handle multiple items in a similar fashion that the visual studio property grid functions.  That is to say that when multiple items are [...]]]></description>
			<content:encoded><![CDATA[<h1>The Problem</h1>
<p>We have a list of editable items (maybe displayed in a list view), and we have an item editor that can edit a single item.  We want to make our editor handle multiple items in a similar fashion that the visual studio property grid functions.  That is to say that when multiple items are selected, editable fields which are similar across all selected items are displayed, and fields that differ are blank.  The main problem here is that you can&#8217;t really databind to a collection of things, not in the sense that we want to solve this problem.  There is no straight forward way of doing this, so my solution is to create an object aggregator class that simulates a single object but in reality handles an enumeration of objects.</p>
<p>I can&#8217;t post any code because, while it does work, it is far from polished and i hate to publish unpolished code.  My description of how to do things should be more than enough for anyone to take a solution away from this post.</p>
<h1>The Solution</h1>
<p>Create a class called <strong>ObjectAggregator&lt;T&gt;</strong>.  Implement <strong>ICustomTypeDescriptor</strong> and <strong>INotifyPropertyChanged</strong>.  Add a public property called Objects which is an <strong>Enumerable&lt;T&gt;</strong>, this will store our object collection to aggregate.  The constructor should take the object collection and store it in the property.  Now implement the <strong>ICustomTypeDescriptor</strong>, almost all function and property implementations should look like &#8220;<strong>return TypeDescriptor.XXX(typeof(T));</strong>&#8221;  Basically, we are just passing the type description logic onto the actual type we are aggregating.  The exceptions are the GetProperties and GetPropertyOwner functions, this is where we customize things.  GetPropertyOwner just needs to return this, GetProperties is where the real fun occurs.</p>
<h2>Get Properties</h2>
<p>The empty parameter prototype can just call the other function with null as a parameter (this may be done in the aggregate type&#8217;s logic, but do it here just in case).  As for the standard <strong>GetProperties(Attribute[])</strong>, first get your original list of property descriptors by calling <strong>TypeDescriptor.GetProperties(typeof(T), attributes);.</strong> Now you can use Cast and Select to generate a list of <strong>ObjectAggregatorPropertyDescriptor&lt;T&gt; </strong>instances (more on this class below).  Now bundle your list up in a <strong>PropertyDescriptorCollection </strong>(by using ToArray) and return it.</p>
<h2>ObjectAggregatorPropertyDescriptor&lt;T&gt;</h2>
<p>This class will inherit from PropertyDescriptor and use the same generic type as the aggregator.  Your constructor will have to take a property descriptor (necessity of the base class), and you should store this paramater locally in a private property.  Now again, most of the property descriptor implementation is pass through.  The only important implementations are where we get or set data, <strong>GetValue</strong>, <strong>SetValue</strong>, and <strong>ResetValue</strong>.  This is because we must aggregate the object collecton held in the type descriptor.  So, most of your implementations should look something like <strong>BasePropertyDescriptor.XXX(component)</strong>.  For the Set and Reset, just cast the component to the aggregator and iterate over the object collection performing the Set or Reset on each object (i.e. <strong>BasePropertyDescriptor.Reset(obj)</strong>).  As for get, i will post some code because describing LINQ is less fun:</p>
<pre>return (component as ObjectAggregator).Objects.Select(x =&gt; BasePropertyDescriptor.GetValue(x)).Distinct().SingleOrDefault();</pre>
<p>That may look a little crazy, but it&#8217;s actually quite simple.  Convert each object into the value returned by the property descriptor, squeeze the list down to unique values and give use the only value (when every object has the same value) or the default for the value type (when values differ between objects).</p>
<h1>Thoughts</h1>
<p>This is a crappy implementation, but it is dead simple, and it works for most simple use cases.  There are things i didn&#8217;t go over which could be considered improvements.  I didn&#8217;t talk about INotifyPropertyChanged, but this is pretty straight forward, push out any changes to any objects in the aggregator as if they were its own.  Ideally, all your property values would be Nullable so that value collisions are actually properly handled as a collision (rather than just using the default value), this is especially true for value types where a collision may hinder the experience (think bools).  I can&#8217;t remember, but i think calling GetPropertyOwner is ideal as well, it&#8217;s been a while since i really dived into custom type descriptors.  Finally, if you wanted to really make this robust, you would handle the scenario of multiple object types.  It&#8217;s not too much more code, but probably quite messy if you have name/type collisions, since you would really have to pick how to handle that yourself, there is no default way.  I think the property grid would likely filter out any name/type collisions (i.e. the property &#8220;Flag&#8221; is a bool on one object and an Enum on another object in the same collection).</p>
<p>Anyways, this is <strong>*A*</strong> way to solve this problem, not the most elegant, but definitely on the path to the most elegant.  This would definitely need some work to function in a more complicated scenario (with converters, editors, attributes, etc&#8230;).  But in the end, it does (poorly) what i intended it to do, that is allow me to databind a single field to an object collection.  I would love to hear of any other ways to accomplish this task.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.errorok.com/2010/11/12/220/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrade rtorrent in karmic 9.10 THE EASY WAY</title>
		<link>http://blog.errorok.com/2010/02/26/191/</link>
		<comments>http://blog.errorok.com/2010/02/26/191/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 23:37:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[ppa]]></category>
		<category><![CDATA[rtorrent]]></category>
		<category><![CDATA[rutorrent]]></category>

		<guid isPermaLink="false">http://blog.errorok.com/?p=191</guid>
		<description><![CDATA[This is just a quick follow-up to my earlier post.  I now have the rtorrent package source up and running on my ppa.  So now you just need to do the following:

echo -e "deb http://ppa.launchpad.net/patricksissons/rtorrent/ubuntu karmic main \ndeb-src http://ppa.launchpad.net/patricksissons/rtorrent/ubuntu karmic main" &#124; sudo tee /etc/apt/sources.list.d/rtorrent.list &#038;&#038; sudo apt-get update &#038;&#038; sudo apt-get install [...]]]></description>
			<content:encoded><![CDATA[<p>This is just a quick follow-up to my earlier post.  I now have the rtorrent package source up and running on my ppa.  So now you just need to do the following:<br />
<code><br />
echo -e "deb http://ppa.launchpad.net/patricksissons/rtorrent/ubuntu karmic main \ndeb-src http://ppa.launchpad.net/patricksissons/rtorrent/ubuntu karmic main" | sudo tee /etc/apt/sources.list.d/rtorrent.list &#038;&#038; sudo apt-get update &#038;&#038; sudo apt-get install rtorrent<br />
</code></p>
<p>This will add my rtorrent ppa to your custom sources, update your source cache, then install the updated version of rtorrent (as well as libtorrent and xmlrpc).  Combine this with <a href="http://code.google.com/p/rutorrent/" target="_blank">rutorrent</a> and you have a pretty sweet headless torrent server.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.errorok.com/2010/02/26/191/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Launchpad PPA&#8217;s</title>
		<link>http://blog.errorok.com/2010/02/24/186/</link>
		<comments>http://blog.errorok.com/2010/02/24/186/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 21:02:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[launchpad]]></category>
		<category><![CDATA[packages]]></category>
		<category><![CDATA[ppa]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.errorok.com/?p=186</guid>
		<description><![CDATA[So after discovering that my quick and dirty rtorrent fix didn&#8217;t actually fix what i needed it to (xmlrpc stuff, specifically), I decided to instead look into setting up a ppa on launchpad to host some of my custom packages.  So here is a quick guide on how to do this:
first, some things you [...]]]></description>
			<content:encoded><![CDATA[<p>So after discovering that my quick and dirty rtorrent fix didn&#8217;t actually fix what i needed it to (xmlrpc stuff, specifically), I decided to instead look into setting up a ppa on launchpad to host some of my custom packages.  So here is a quick guide on how to do this:</p>
<p>first, some things you will need to install:<br />
<code>sudo apt-get install dput devscripts</code><br />
of course, you&#8217;ll need some of the usual stuff like build-essentials and other common dev packages.  dput is used to upload your source packages to your ppa, and devscripts contains some useful debian package scripts, such as debuild which is used to build your package.</p>
<p>now, create a gpg key for your ppa (or use an existing one if you have one)<br />
simply use gpg &#8211;gen-key to generate a key (use the defaults, unless you want to get more specific)<br />
if you already have a set of keys on another machine, you can export/import the public and private keys to your other machine.  If you get into trouble with not enough entropy (happens when your compile machine is headless and you do everything through ssh), then try installing rng-tools and set your device to /dev/urandom (in /etc/default/rng-tools) then start the service.  This will generate entropy for you.</p>
<p>Now setup your own ppa.  First you&#8217;ll need a launchpad account, then you just need to authenticate yourself and create a new ppa.  I won&#8217;t detail this process, but you can probably get a good idea from here: http://blog.launchpad.net/ppa/personal-package-archives-for-everyone</p>
<p>Now grab your source package as well as its build dependencies:<br />
<code>sudo apt-get build-dep PACKAGE<br />
apt-get source PACKAGE</code><br />
note that you don&#8217;t need to sudo when getting package sources.  If you are upgrading the package using the latest version, things can get a little wonky because ubuntu packages are usually customized with patches, and these patches often don&#8217;t work with bleeding edge source.  None the less you can give it a shot, simply grab the source for your package (not through apt, but from svn, git, http, etc&#8230;) and then copy the debian directory from the ubuntu source directory to your newer source directory.  You will need to modify the changelog and create a new entry for your package (with an updated version).  Alternatively, you can use dch to do this.  Once you have your source set up, you have to build the source package.  I recommend building the binary first, but this is not necessary, it just helps to for testing installation of the package and other things.  to build the source package:<br />
<code>debuild -S -sa</code><br />
this will generate a source package in the parent directory.  Once this finishes, you can upload it to you ppa.</p>
<p>to upload your package to your ppa, just run:<br />
<code>dput PPA PACKAGE_source.changes</code><br />
PPA will be something like ppa:USER_NAME/PPA_NAME<br />
the changes file will have been created as a part of the source package creation.<br />
this will ask you to enter your gpg password, and then upload the files to the launchpad servers.  In a few minutes your package will be built and you&#8217;ll get a notice saying it was successful or not.</p>
<p>Caveats!  They exist!  some things i have found which are slightly annoying are the following:<br />
you cannot re-upload (re-build) a package.  This is useful if you have a dependency issue, the only fix is to increment the version and re-upload (please correct me if there is a better solution).<br />
deleting packages is not very clear what happens, a deleted package still exists for quite some time on the server.  There appears to be no notice of a package being purged, it just randomly stops existing.</p>
<p>p.s. updated rtorrent ppa will come soon, if you really want to get it now, you can use this package source:<br />
<em>deb http://ppa.launchpad.net/patricksissons/pjs/ubuntu karmic main</em><br />
this is my development ppa, so it may contain things you don&#8217;t actually want to install.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.errorok.com/2010/02/24/186/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.944 seconds -->

