protected void DependencySatisfied(IHandler handler, ref bool stateChanged)
{
// Check within the handler
if (customParameters != null && customParameters.Count != 0)
{
DependencyModel[] dependencies = Union(DependenciesByService.Values, DependenciesByKey.Values);
foreach (DependencyModel dependency in dependencies)
{
if (!HasCustomParameter(dependency.DependencyKey))
{
continue;
}
if (dependency.DependencyType == DependencyType.Service)
{
DependenciesByService.Remove(dependency.TargetType);
}
else
{
DependenciesByKey.Remove(dependency.DependencyKey);
}
}
}
// Check within the Kernel
Type[] services = new Type[DependenciesByService.Count];
DependenciesByService.Keys.CopyTo(services, 0);
foreach (Type service in services)
{
if (HasValidComponent(service))
{
DependenciesByService.Remove(service);
AddGraphDependency(kernel.GetHandler(service).ComponentModel);
}
}
String[] keys = new String[DependenciesByKey.Keys.Count];
DependenciesByKey.Keys.CopyTo(keys, 0);
foreach (String compKey in keys)
{
if (HasValidComponent(compKey) || HasCustomParameter(compKey))
{
DependenciesByKey.Remove(compKey);
AddGraphDependency(kernel.GetHandler(compKey).ComponentModel);
}
}
if (DependenciesByService.Count == 0 && DependenciesByKey.Count == 0)
{
SetNewState(HandlerState.Valid);
stateChanged = true;
DisconnectEvents();
// We don't need these anymore
dependenciesByKey = null;
dependenciesByService = null;
}
}