private void CloneParentProperties(ComponentModel newModel)
{
// Inherits from LifeStyle's context.
newModel.LifestyleType = ComponentModel.LifestyleType;
// Inherit the parent handler interceptors.
foreach (InterceptorReference interceptor in ComponentModel.Interceptors)
{
// we need to check that we are not adding the inteceptor again, if it was added
// by a facility already
newModel.Interceptors.AddIfNotInCollection(interceptor);
}
if (ComponentModel.HasCustomDependencies)
{
var dependencies = newModel.CustomDependencies;
foreach (DictionaryEntry dependency in ComponentModel.CustomDependencies)
{
dependencies.Add(dependency.Key, dependency.Value);
}
}
var metaDescriptors = ComponentModel.GetMetaDescriptors(ensureExists: false);
if (metaDescriptors != null)
{
foreach (var descriptor in metaDescriptors)
{
descriptor.ConfigureComponentModel(Kernel, newModel);
}
}
}