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
We use the Ninject factory extensions in a project that I'm working on and we have come across the need in some cases for async instantiation which has come into conflict with some of the auto-implemented factory goodness we have been enjoying.
The basic concept is to allow the factory extensions to work with methods (func or auto-implemented interface method contracts) that return a result of Task.
public class MyClass
{
public MyClass(int nonServiceDependency, IMyService serviceDependency)
{
...
}
}
public class IMyClassFactory
{
public async Task<MyClass> CreateMyClassAsync(int nonServiceDependency);
}
And usage would look something like.
kernel.Bind<IMyClassFactory>().ToFactory();
var factory = kernel.Get<IMyClassFactory>();
var instanceFromFactory = await factory.CreateMyClassAsync(42);
// or alternatively
var func = kernel.Get<Func<int, Task<MyClass>>>();
var instanceFromFunc = await func(42);
The text was updated successfully, but these errors were encountered:
We use the Ninject factory extensions in a project that I'm working on and we have come across the need in some cases for async instantiation which has come into conflict with some of the auto-implemented factory goodness we have been enjoying.
The basic concept is to allow the factory extensions to work with methods (func or auto-implemented interface method contracts) that return a result of Task.
And usage would look something like.
The text was updated successfully, but these errors were encountered: