/// <summary> /// Define the requested type of a binding. /// /// See class Binding. /// /// Example: /// /// Bind<ISomeObject>.To<SomeClass>() - always injects a new instance when "ISomeObject" is requested /// Bind<ISomeOther>.ToInstance(someObject) - always injects "someObject" when "ISomeOther" is requested /// </summary> /// <typeparam name="TType">The requested type</typeparam> /// <returns>A InjectionBinding</returns> public InjectionBinding Bind <TType>() { var type = typeof(TType); var binding = new InjectionBinding(type); Bindings.Add(binding); return(binding); }
/// <summary> /// Get an instancy by applying the given Binding /// </summary> /// <param name="injectionBinding">The binding to use</param> /// <param name="bindings">All other bindings</param> /// <returns>The create instance</returns> public object Instantiate(InjectionBinding injectionBinding, List <InjectionBinding> bindings) { return(InstantiateInternal(injectionBinding.BoundTo, bindings, injectionBinding.GetInstance, injectionBinding.DoFieldAndPropertyInjection)); }