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

EnsureDependenciesCanBeSatisfied() protected method

Checks if the handler is able to, at very least, satisfy the dependencies for the constructor with less parameters
For each non*optional dependency, the implementation will invoke AddDependency
protected EnsureDependenciesCanBeSatisfied ( ) : void
return void
		protected virtual void EnsureDependenciesCanBeSatisfied()
		{
			// Custom activators should deal with this case
			if (ComponentModel.Constructors.Count == 0)
			{
				return;
			}

			// Property dependencies may not be optional

			foreach (PropertySet property in ComponentModel.Properties)
			{
				DependencyModel dependency = property.Dependency;

				if (!dependency.IsOptional &&
					(dependency.DependencyType == DependencyType.Service ||
					 dependency.DependencyType == DependencyType.ServiceOverride))
				{
					AddDependency(dependency);
				}
			}

			// The following dependencies were added by - for example - 
			// facilities, for some reason, and we need to satisfy the non-optional

			foreach (DependencyModel dependency in ComponentModel.Dependencies)
			{
				if (!dependency.IsOptional &&
					(dependency.DependencyType == DependencyType.Service ||
					 dependency.DependencyType == DependencyType.ServiceOverride))
				{
					AddDependency(dependency);
				}
			}

			// We need to satisfy at least the constructor 
			// with fewer arguments

			ConstructorCandidate candidate = ComponentModel.Constructors.FewerArgumentsCandidate;

			foreach (DependencyModel dependency in candidate.Dependencies)
			{
				if (dependency.DependencyType == DependencyType.Service ||
					dependency.DependencyType == DependencyType.ServiceOverride)
				{
					AddDependency(dependency);
				}
			}

			if (state == HandlerState.Valid)
			{
				DisconnectEvents();
			}
		}