Grace icon indicating copy to clipboard operation
Grace copied to clipboard

Updated documentation

Open SuperJMN opened this issue 5 years ago • 7 comments

For example:

How is TypesThat used? How do we correctly use ExportAssembly

More samples regarding fluent API usage.

For example, I did this:

To register all the Tools in a given assembly as Tool, so an injection like IEnumerable<Tool> works I did:

registrationBlock.Export(toolType.Assembly.ExportedTypes
        .Where(TypesThat.AreBasedOn<Tool>())
        .Where(x => !x.IsAbstract))
    .ByTypes(type => new[] { toolType });

Is there a better, simplified way to achieve that?

Another example. Does this look OK?

registrationBlock.ExportAssemblies(Assemblies.AppDomainAssemblies)
    .Where(y => typeof(ISection).IsAssignableFrom(y))
    .ByInterface<ISection>()
    .ByInterface<IBusy>()
    .ByType()
    .ExportAttributedTypes()
    .Lifestyle.Singleton();

BTW: I could collaborate with the docs, but I don't know how to do it 😥

SuperJMN avatar Oct 19 '19 11:10 SuperJMN

Hi José,

I’m out of town today but I’ll reply tomorrow with an in-depth answer

ipjohnson avatar Oct 19 '19 14:10 ipjohnson

So looking at your examples both look correct. I think ultimately it really comes down to do you like using linq yourself or do you want to have the container do it for you.

ipjohnson avatar Oct 23 '19 10:10 ipjohnson

that seems to Grace does not provide simplified inside the bulk registration API ?

sgf avatar Nov 27 '19 02:11 sgf

Hi @sgf

What type of simplification are you looking for?

ipjohnson avatar Nov 27 '19 09:11 ipjohnson

like these: https://github.com/z4kn4fein/stashbox/wiki/Assembly-registration https://github.com/seesharper/LightInject#assembly-scanning

In fact, it's not essential, but if any easier

sgf avatar Nov 27 '19 09:11 sgf

@sgf there are a number of export functions that work on lists of types that are quite similar to what you posted for example ExportAssemblyContaining<T>.

What are you looking for specifically?

ipjohnson avatar Nov 27 '19 09:11 ipjohnson

@sgf there are a number of export functions that work on lists of types that are quite similar to what you posted for example ExportAssemblyContaining<T>.

What are you looking for specifically?

I'm sorry, I didn't find it in the documentation. So I thought your project was not supported. Now, you tell me that ExportAssemblyContaining<T>, thank you very much.

It seems that the problem I raised does not exist. 😂

sgf avatar Nov 27 '19 10:11 sgf