Esempio n. 1
0
        /// <summary>
        ///     Registers the specified binding.
        /// </summary>
        /// <param name="binding">The binding to add.</param>
        public override void AddBinding(IBinding binding)
        {
            Ensure.ArgumentNotNull(binding, "binding");

            Kernel.AddBinding(binding);
            Bindings.Add(binding);
        }
Esempio n. 2
0
        /*----------------------------------------------------------------------------------------*/
        #region Protected Methods
        /// <summary>
        /// Begins a binding definition.
        /// </summary>
        /// <param name="type">The service type to bind from.</param>
        /// <returns>A binding builder.</returns>
        protected virtual TBindingBuilder DoBind(Type type)
        {
            if (Logger.IsDebugEnabled)
            {
                Logger.Debug("Declaring binding for service {0}", Format.Type(type));
            }

            IBinding binding = Kernel.Components.BindingFactory.Create(type);

#if !NO_STACKTRACE
            if (Kernel.Options.GenerateDebugInfo)
            {
                binding.DebugInfo = DebugInfo.FromStackTrace();
            }
#endif

            // Register the binding in the kernel.
            Kernel.AddBinding(binding);

            // Store the binding to allow it to be un-registered if the module is unloaded.
            Bindings.Add(binding);

            return(CreateBindingBuilder(binding));
        }