ipjohnson / Grace

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

Depricate ExportInstance(delegate) methods in favor of ExportFactory<...> methods #89

Closed ipjohnson closed 7 years ago

ipjohnson commented 7 years ago

With the introduction of the ExportFactory method the ExportInstance(delegate) methods have become obsolete. As well as being obsolete the behavior is not consistent with how ExportInstance<T>(T value) and leads to confusion as seen in issue #86. With this in mind I'm going to mark the methods as obsolete in 6.2 and plan to remove them at some point later for a major version number release.

darkcamper commented 7 years ago

@ipjohnson How about adding an "ExportFuncWithContext" extension method (that maps to ExportFunc<IExportLocatorScope, StaticInjectionContext, IInjectionContext,T>) to IExportRegistrationBlock?

I think it would make easier the transition from the obsolete ExportInstance method when you just want to do a context-base activation, and would provide design-time support for tools such as Resharper to suggest you the signature of the delegate.

ipjohnson commented 7 years ago

@darkcamper sounds like a good idea, something like this?

public static IFluentExportInstanceConfiguration<T> ExportFuncWithContext<T>(
     this IExportRegistrationBlock block, 
     Func<IExportLocatorScope, StaticInjectionContext, IInjectionContext,T> func)
{
   return block.ExportFactory(func);
}
darkcamper commented 7 years ago

@ipjohnson Yeah! That's exactly what I had in mind.