CodeGenerationUtilities.SortDomainClassesByInheritance<T> Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Sort a collection of DomainClasses based on relative inheritance relationships. The most derived one will appear first in the sort result. This is used in following situation: Say there're 4 DomainClasses A, B, C and D. You need to generate some code like following: ... A a = obj as A; if (a != null) ... B b = obj as B; if (b != null) ... C c = obj as C; if (c != null) ... D d = obj as D; if (d != null) ... ... If C derives from A, the above code is wrong; the correct code should check for C first before checking for A. That's why this method should be called to sorted the DomainClasses in inheritance order, and the generated code will look like: ... C c = obj as C; if (c != null) ... A a = obj as A; if (a != null) ... B b = obj as B; if (b != null) ... D d = obj as D; if (d != null) ... ...
public:
generic <typename T>
where T : Microsoft::VisualStudio::Modeling::DslDefinition::DomainClass static System::Collections::Generic::IEnumerable<T> ^ SortDomainClassesByInheritance(System::Collections::Generic::IEnumerable<T> ^ input);
public static System.Collections.Generic.IEnumerable<T> SortDomainClassesByInheritance<T> (System.Collections.Generic.IEnumerable<T> input) where T : Microsoft.VisualStudio.Modeling.DslDefinition.DomainClass;
static member SortDomainClassesByInheritance : seq<'T (requires 'T :> Microsoft.VisualStudio.Modeling.DslDefinition.DomainClass)> -> seq<'T (requires 'T :> Microsoft.VisualStudio.Modeling.DslDefinition.DomainClass)> (requires 'T :> Microsoft.VisualStudio.Modeling.DslDefinition.DomainClass)
Public Shared Function SortDomainClassesByInheritance(Of T As DomainClass) (input As IEnumerable(Of T)) As IEnumerable(Of T)
Type Parameters
- T
Parameters
- input
- IEnumerable<T>