Beispiel #1
0
        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);
        }
Beispiel #2
0
        /// <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);
        }
Beispiel #3
0
        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);
        }