protected virtual void ReadLifestyleFromType(ComponentModel model)
{
var attributes = model.Implementation.GetAttributes<LifestyleAttribute>();
if (attributes.Length == 0)
{
return;
}
var attribute = attributes[0];
model.LifestyleType = attribute.Lifestyle;
if (model.LifestyleType == LifestyleType.Custom)
{
var custom = (CustomLifestyleAttribute)attribute;
ValidateTypeFromAttribute(custom.CustomLifestyleType, typeof(ILifestyleManager), "CustomLifestyleType");
model.CustomLifestyle = custom.CustomLifestyleType;
}
else if (model.LifestyleType == LifestyleType.Pooled)
{
var pooled = (PooledAttribute)attribute;
model.ExtendedProperties[ExtendedPropertiesConstants.Pool_InitialPoolSize] = pooled.InitialPoolSize;
model.ExtendedProperties[ExtendedPropertiesConstants.Pool_MaxPoolSize] = pooled.MaxPoolSize;
}
else if (model.LifestyleType == LifestyleType.Bound)
{
var binder = ExtractBinder(((BoundToAttribute)attribute).ScopeRootBinderType, model.Name);
model.ExtendedProperties[Constants.ScopeRootSelector] = binder;
}
else if (model.LifestyleType == LifestyleType.Scoped)
{
var scoped = (ScopedAttribute)attribute;
if (scoped.ScopeAccessorType != null)
{
ValidateTypeFromAttribute(scoped.ScopeAccessorType, typeof(IScopeAccessor), "ScopeAccessorType");
model.ExtendedProperties[Constants.ScopeAccessorType] = scoped.ScopeAccessorType;
}
}
}