You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Autoexport all types by interface by specific key #205
Can you help me with this scenario...
I want to scan all types in specific assembly and export all types which impl specific interface...but I want to export by key which defined thru attribute. And I want to export with the specific lifestyle.
[Foo("a")]
class A: IExportInterface {}
[Foo("b")]
class B: IExportInterface {}
// ... after apply some grace magick ...
container.Locate<IExportInterface>(withKey: "a") // Yeah, It`a instance of A
container.Locate<IExportInterface>(withKey: "b") // Yeah, It`a instance of B
I feel that there are some excessive descriptions.
I think that add ability to provide key provider factory method during export is good choice.
And we can combine type that identify assembly with export type.
I hesitate to add an ExportAssemblyContaining<T, T2, T3>() , I'd be open to something like ExportAssmbliesContaining(params Type[] types) that way there is only one new extension to cover all cases.
There is already a ByKeyedTypes method that lets you export a set by keyed types. I think an extension method like this would be what you want.
I'll look at putting this into a preview release in the next week. Did you want the extension ExportAssmbliesContaining(typeof(ClassA), typeof(ClassB))?
Activity
mcdis commentedon Mar 2, 2019
Can(How) I use interface IExportKeyedTypeAttribute?
mcdis commentedon Mar 2, 2019
Tried this code and looks like it works...
ipjohnson commentedon Mar 3, 2019
Hi @mcdis
I’ve been away for the weekend but I’ll take a look this evening and put something together.
mcdis commentedon Mar 4, 2019
I feel that there are some excessive descriptions.
I think that add ability to provide key provider factory method during export is good choice.
And we can combine type that identify assembly with export type.
Or some extra method
OfInterface<IFoo>()~.Where(_t => typeof(IFoo).IsAssignableFrom(_t)).ByInterface<IFoo>()ipjohnson commentedon Mar 4, 2019
Hi @mcdis
I hesitate to add an
ExportAssemblyContaining<T, T2, T3>(), I'd be open to something likeExportAssmbliesContaining(params Type[] types)that way there is only one new extension to cover all cases.There is already a
ByKeyedTypesmethod that lets you export a set by keyed types. I think an extension method like this would be what you want.mcdis commentedon Mar 5, 2019
Hi @ipjohnson,
That extension looks good!
ipjohnson commentedon Mar 7, 2019
I'll look at putting this into a preview release in the next week. Did you want the extension
ExportAssmbliesContaining(typeof(ClassA), typeof(ClassB))?Adding extension for issue #205
ipjohnson commentedon Apr 23, 2019
I'm going to close this out as it will be released in 7.0