public void Register(Type service, object instance, IScope scope = null) { var strategy = new ConstantStrategy(instance); var binding = new StandardBinding(service, null, strategy) { Scope = scope }; _bindingManager.Register(binding); }
/// <summary> /// Adds a service to the provider, and adds a binding to the Kernel, allowing the service to be part of the dependency /// injection machanism. /// </summary> /// <param name="contractType">Service's contract type.</param> /// <param name="service">Service implementation (must support contract's type)</param> public override void RegisterService(Type contractType, IService service) { base.RegisterService(contractType, service); //Create a special binding for services IBinding binding; binding = new StandardBinding(Kernel, contractType); binding.Provider = new ServiceProvider(contractType, service); Kernel.AddBinding(binding); }
public void Register(Type service, Type target, IScope scope = null) { ThrowIfTargetIsMissing(service, target); var strategy = _activationManager.GetStrategyFor(target); var binding = new StandardBinding(service, target, strategy) { Scope = scope }; _bindingManager.Register(binding); }