/// <summary> /// <para>Create a new generic asyncronous StackWrapper from the <typeparamref name="TEntry"/> /// entry class with the specified delegate to apply as digest.</para> /// <para>If no settings are specified the default ones <seealso cref="StackWrapperSettings.Default"/> will be used.</para> /// examples: /// <code>Injector.AsyncFrom<MyClass>( (e,i,t) => e.Digest(i,t) )</code> /// <code>Injector.AsyncFrom( async (MyClass e, object parameter, CancellationToken token) => e.Digest(parameter, token) )</code> /// tip: you can use tuples to pass multiple arguments if needed<br/> /// </summary> /// <typeparam name="TEntry">class from which start injection</typeparam> /// <typeparam name="TIn">type of elements in input</typeparam> /// <typeparam name="TOut">type of elements in output</typeparam> /// <param name="digest">delegate used to call the relative method to perform on submitted items</param> /// <param name="settings">the settings to use with this object. If null, use default.</param> /// <returns>The created asyncronous wrapper</returns> /// <exception cref="InvalidEntryTypeException"></exception> /// <exception cref="NotAServiceException"></exception> /// <exception cref="ServiceNotFoundException"></exception> /// <exception cref="ImplementationNotFoundException"></exception> /// <exception cref="StackInjectorException"></exception> public static IAsyncStackWrapper <TEntry, TIn, TOut> AsyncFrom <TEntry, TIn, TOut> ( AsyncStackDigest <TEntry, TIn, TOut> digest, StackWrapperSettings settings = null ) { if (settings == null) { settings = StackWrapperSettings.Default; } // create the core and wrap it var core = new InjectionCore(settings) { EntryType = typeof(TEntry) }; var wrapper = new AsyncStackWrapper <TEntry, TIn, TOut>(core) { StackDigest = digest }; // initialize the injection process core.Serve(); return(wrapper); }
public IAsyncStackWrapper <TEntry, TIn, TOut> ToAsyncWrapper <TEntry, TIn, TOut> (AsyncStackDigest <TEntry, TIn, TOut> digest) { var wrapper = new AsyncStackWrapper <TEntry, TIn, TOut>(this.clonedCore) { StackDigest = digest }; this.clonedCore.EntryType = typeof(TEntry); this.clonedCore.Serve(cloned: true); return(wrapper); }