/*----------------------------------------------------------------------------------------*/ #region Constructors /// <summary> /// Creates a new StandardBinding. /// </summary> /// <param name="kernel">The kernel that is creating the binding.</param> /// <param name="service">The service type to bind from.</param> public StandardBinding(IKernel kernel, Type service) { Ensure.ArgumentNotNull(kernel, "kernel"); Ensure.ArgumentNotNull(service, "service"); Kernel = kernel; Service = service; Heuristics = new HeuristicCollection(); Parameters = new ParameterCollection(); Components = new StandardComponentContainer(kernel, kernel.Components); }
/*----------------------------------------------------------------------------------------*/ #region Protected Methods /// <summary> /// Connects all kernel components. Called during initialization of the kernel. /// </summary> protected override IComponentContainer InitializeComponents() { var components = new StandardComponentContainer(this); components.Connect<ILoggerFactory>(new NullLoggerFactory()); components.Connect<IModuleManager>(new StandardModuleManager()); components.Connect<IActivator>(new StandardActivator()); components.Connect<IPlanner>(new StandardPlanner()); components.Connect<IConverter>(new StandardConverter()); components.Connect<ITracker>(new StandardTracker()); components.Connect<IBindingRegistry>(new StandardBindingRegistry()); components.Connect<IBindingSelector>(new StandardBindingSelector()); components.Connect<IBindingFactory>(new StandardBindingFactory()); components.Connect<IActivationPlanFactory>(new StandardActivationPlanFactory()); components.Connect<IMemberSelector>(new StandardMemberSelector()); components.Connect<IDirectiveFactory>(new StandardDirectiveFactory()); components.Connect<IProviderFactory>(new StandardProviderFactory()); components.Connect<IResolverFactory>(new StandardResolverFactory()); components.Connect<IContextFactory>(new StandardContextFactory()); components.Connect<IScopeFactory>(new StandardScopeFactory()); components.Connect<IRequestFactory>(new StandardRequestFactory()); components.Connect<IAdviceFactory>(new StandardAdviceFactory()); components.Connect<IAdviceRegistry>(new StandardAdviceRegistry()); #if NO_LCG // If the target platform doesn't have DynamicMethod support, we can't use DynamicInjectorFactory. components.Connect<IInjectorFactory>(new ReflectionInjectorFactory()); #else if (Options.UseReflectionBasedInjection) components.Connect<IInjectorFactory>(new ReflectionInjectorFactory()); else components.Connect<IInjectorFactory>(new DynamicInjectorFactory()); #endif return components; }