ipjohnson / Grace

Grace is a feature rich dependency injection container library
MIT License
336 stars 33 forks source link

Chain configuration #124

Closed mcdis closed 6 years ago

mcdis commented 6 years ago

Think does it possible to make configuration more simple and more chainy (more compact): example: c - container

c.Configure(_=>_.ExportAs<A,IA>()
  .ExportAs<B,IB>()
  .ExportAs<C,IC>());

another example

c.ExportAs<B,IB>().ExportAs<C,IC>().ExportAs<A,IA>().Configure()
ipjohnson commented 6 years ago

Currently the way ExportAs<T> returns a configuration object that allows you to configure the lifestyle and other facets.

I'd be open to adding another extension method that goes off of container or is named something else like Register

mcdis commented 6 years ago

May be add some .Configure() alias? For example

IInjectionScope Cfg(this IInjectionScope _this, Action<IExportRegistrationBlock> _cfg);

or use another interface in IExportRegistrationBlock that provide chainy technique but inside it's work over IExportRegistrationBlock but syntax more compact

ipjohnson commented 6 years ago

I'm going to close this out as C# extensions can be used to simulate this.