Skip to content

improve open generics with constraints? #57

@lsoft

Description

@lsoft

now we have:

//the following statement will bind A0 and A2; A1 will be excluded due to IExclude<>
ScanInAssembliesWith<A0>()
    .SelectAllWithOpenGeneric<IA<object, object>>() //generic arguments 'object' means NOTHING! it will be removed by Dpdt, so IA<object, object> will be transformed into IA<,> (open generic)
    .ExcludeAllWithOpenGeneric<IExclude<object, object>>() //again, 'object' means nothing, as above
    .FromAllInterfaces()
    .ToItself()
    .WithSingletonScope()
    ;

we may want to add an additional constraints for conventional search:

//the following statement will bind A0 and A2; A1 will be excluded due to IExclude<>
ScanInAssembliesWith<A0>()
    .SelectAllWithOpenGeneric<IA<object, object>>() //generic arguments 'object' means NOTHING! it will be removed by Dpdt, so IA<object, object> will be transformed into IA<,> (open generic)
    .ApplyGenericConstraintChildAt<1, SomeClass>() //applies a generic constraint at second generic parameter IA<,here> to be derived from SomeClass; so IA<,> transformed to IA<,any child of SomeClass>
    //ApplyGenericConstraintChildAt applied to the previous SelectAllWithOpenGeneric declaration
    .ExcludeAllWithOpenGeneric<IExclude<object, object>>() //again, 'object' means nothing, as above
    .ApplyGenericConstraintChildOrItselfAt<0, ExcludedClass>() //applies a generic constraint at first generic parameter IExclude<here,> to be derived from ExcludedClass; so IExclude<,> transformed to IExclude<any child of ExcludedClass or itself,>
    .FromAllInterfaces()
    .ToItself()
    .WithSingletonScope()
    ;

//new constraints:
//ApplyGenericConstraintChildAt
//ApplyGenericConstraintChildOrItselfAt

or:

//ApplyGenericConstraint<ChildAt<...>>
//ApplyGenericConstraint<ChildOrItselfAt<...>>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions