Delen via


CodeGenerationUtilities.SortDomainClassesByInheritance<T> Method

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) ... ...

Namespace:  Microsoft.VisualStudio.Modeling.DslDefinition
Assembly:  Microsoft.VisualStudio.Modeling.Sdk.DslDefinition.12.0 (in Microsoft.VisualStudio.Modeling.Sdk.DslDefinition.12.0.dll)

Syntax

'Declaration
Public Shared Function SortDomainClassesByInheritance(Of T As DomainClass) ( _
    input As IEnumerable(Of T) _
) As IEnumerable(Of T)
public static IEnumerable<T> SortDomainClassesByInheritance<T>(
    IEnumerable<T> input
)
where T : DomainClass
public:
generic<typename T>
where T : DomainClass 
static IEnumerable<T>^ SortDomainClassesByInheritance(
    IEnumerable<T>^ input
)
static member SortDomainClassesByInheritance : 
        input:IEnumerable<'T> -> IEnumerable<'T>  when 'T : DomainClass
JScript does not support generic types or methods.

Type Parameters

  • T

Parameters

Return Value

Type: System.Collections.Generic.IEnumerable<T>

.NET Framework Security

See Also

Reference

CodeGenerationUtilities Class

Microsoft.VisualStudio.Modeling.DslDefinition Namespace