コード例 #1
0
        /*----------------------------------------------------------------------------------------*/
        /// <summary>
        /// Disconnects a component from the kernel.
        /// </summary>
        /// <param name="type">The service that the component provides.</param>
        protected override void DoDisconnect(Type type)
        {
            Ensure.NotDisposed(this);

            lock (_components)
            {
                if (!_components.ContainsKey(type))
                {
                    throw new InvalidOperationException(ExceptionFormatter.KernelHasNoSuchComponent(type));
                }

                IKernelComponent component = _components[type];
                _components.Remove(type);

                component.Disconnect();
                component.Dispose();
            }
        }
コード例 #2
0
        /*----------------------------------------------------------------------------------------*/
        #region Protected Methods
        /// <summary>
        /// Connects a component to the kernel.
        /// </summary>
        /// <param name="type">The service that the component provides.</param>
        /// <param name="component">The instance of the component.</param>
        protected override void DoConnect(Type type, IKernelComponent component)
        {
            Ensure.ArgumentNotNull(type, "type");
            Ensure.ArgumentNotNull(component, "member");
            Ensure.NotDisposed(this);

            lock (_components)
            {
                // Remove the component if it's already been connected.
                if (_components.ContainsKey(type))
                {
                    DoDisconnect(type);
                }

                component.Connect(Kernel);
                _components.Add(type, component);
            }
        }
コード例 #3
0
		/*----------------------------------------------------------------------------------------*/
		#region Protected Methods
		/// <summary>
		/// Connects a component to the kernel.
		/// </summary>
		/// <param name="type">The service that the component provides.</param>
		/// <param name="component">The instance of the component.</param>
		protected override void DoConnect(Type type, IKernelComponent component)
		{
			Ensure.ArgumentNotNull(type, "type");
			Ensure.ArgumentNotNull(component, "member");
			Ensure.NotDisposed(this);

			lock (_components)
			{
				// Remove the component if it's already been connected.
				if (_components.ContainsKey(type))
					DoDisconnect(type);

				component.Connect(Kernel);
				_components.Add(type, component);
			}
		}
コード例 #4
0
 /*----------------------------------------------------------------------------------------*/
 #region Protected Methods
 /// <summary>
 /// Connects a component to the kernel.
 /// </summary>
 /// <param name="type">The service that the component provides.</param>
 /// <param name="component">The instance of the component.</param>
 protected abstract void DoConnect(Type type, IKernelComponent component);
コード例 #5
0
 /*----------------------------------------------------------------------------------------*/
 /// <summary>
 /// Connects a component to the kernel. If a component with the specified service is
 /// already connected, it will be disconnected first.
 /// </summary>
 /// <param name="type">The service that the component provides.</param>
 /// <param name="component">The instance of the component.</param>
 public void Connect(Type type, IKernelComponent component)
 {
     DoConnect(type, component);
 }
コード例 #6
0
 /*----------------------------------------------------------------------------------------*/
 IBindingHeuristicComponentOrParameterSyntax IBindingComponentSyntax.WithComponent(Type type, IKernelComponent component)
 {
     Binding.Components.Connect(type, component);
     return(this);
 }