Castle.MicroKernel.Handlers.AbstractHandler.OnAddedAsChildKernel C# (CSharp) Method

OnAddedAsChildKernel() protected method

Invoked when the container receives a parent container reference.
This method implementation checks whether the parent container is able to supply the dependencies for this handler.
protected OnAddedAsChildKernel ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
		protected void OnAddedAsChildKernel(object sender, EventArgs e)
		{
			if (DependenciesByKey.Count == 0 && DependenciesByService.Count == 0)
			{
				return;
			}

			bool stateChanged = false;

			Type[] services = new Type[DependenciesByService.Count];

			DependenciesByService.Keys.CopyTo(services, 0);

			foreach (Type service in services)
			{
				if (Kernel.Parent.HasComponent(service))
				{
					IHandler handler = Kernel.Parent.GetHandler(service);
					DependencySatisfied(handler, ref stateChanged);
				}
			}

			String[] keys = new String[DependenciesByKey.Count];

			DependenciesByKey.Keys.CopyTo(services, 0);

			foreach (String key in keys)
			{
				if (Kernel.Parent.HasComponent(key))
				{
					IHandler handler = Kernel.Parent.GetHandler(key);
					DependencySatisfied(handler, ref stateChanged);
				}
			}
		}