/// <summary> /// Assigns the provider callback to the building configuration. /// </summary> /// <param name="bindingConfiguration"> /// The building configuration. /// </param> /// <param name="prototype"> /// The prototype. /// </param> public static void AssignProviderCallback(IBindingConfiguration bindingConfiguration, Type prototype) { var provider = new StandardProvider(prototype, null); bindingConfiguration.ProviderCallback = ctx => provider; bindingConfiguration.InitializeProviderCallback = selector => provider.ConstructorScorer = selector.ConstructorScorer; }
/// <summary> /// Gets a callback that creates an instance of the <see cref="StandardProvider"/> /// for the specified type and constructor. /// </summary> /// <param name="prototype">The prototype the provider instance will create.</param> /// <param name="constructor">The constructor.</param> /// <returns>The created callback.</returns> public static Func<IContext, IProvider> GetCreationCallback(Type prototype, ConstructorInfo constructor) { var provider = new StandardProvider(prototype, new SpecificConstructorSelector(constructor)); return ctx => provider; }
/// <summary> /// Gets a callback that creates an instance of the <see cref="StandardProvider"/> /// for the specified type. /// </summary> /// <param name="prototype">The prototype the provider instance will create.</param> /// <param name="selector">The selector.</param> /// <returns>The created callback.</returns> public static Func<IContext, IProvider> GetCreationCallback(Type prototype, ISelector selector) { var provider = new StandardProvider(prototype, selector.ConstructorScorer); return ctx => provider; }
/// <summary> /// Gets a callback that creates an instance of the <see cref="StandardProvider"/> /// for the specified type and constructor. /// </summary> /// <param name="prototype">The prototype the provider instance will create.</param> /// <param name="constructor">The constructor.</param> /// <returns>The created callback.</returns> public static Func <IContext, IProvider> GetCreationCallback(Type prototype, ConstructorInfo constructor) { var provider = new StandardProvider(prototype, new SpecificConstructorSelector(constructor)); return(ctx => provider); }
/// <summary> /// Gets a callback that creates an instance of the <see cref="StandardProvider"/> /// for the specified type. /// </summary> /// <param name="prototype">The prototype the provider instance will create.</param> /// <param name="selector">The selector.</param> /// <returns>The created callback.</returns> public static Func <IContext, IProvider> GetCreationCallback(Type prototype, ISelector selector) { var provider = new StandardProvider(prototype, selector.ConstructorScorer); return(ctx => provider); }