Order dependent types
<p>I have a creative question. I want to give types an order which is dependent on dependencies. :)</p>

<p>Example:</p>

<pre><code>public class Oil
{}

public class Seat
{}

public class Wheel : IDependOn&lt;Oil&gt;
{}

public class Car : IDependOn&lt;Wheel&gt;, IDependOn&lt;Seat&gt;
{}
</code></pre>

<p>So, and now I want to have function (including reflection) which gives me back a <code>Dictionary&lt;Int32, Type&gt;</code> where the <code>Int32</code> index is the order.</p>

<p>The function definition will look like:</p>

<pre><code>public Dictionary&lt;Int32, Type&gt; GetOrderedTypes(List&lt;Type&gt; types);
</code></pre>

<p>The result for this example should be:</p>

<pre><code>&lt;1, Oil&gt;
&lt;2, Seat&gt;
&lt;3, Wheel&gt;
&lt;4, Car&gt;
</code></pre>

<p>The tasks can be much more complex, but will have ever the same logic.</p>

<ul>
<li>Types with no dependencies have the lowest order.</li>
<li>For types with the same dependencies the order is not important.</li>
</ul>

<p>Can anyone help me in this regard?</p>
