public static List<Func<Aspect>> LoadDefaultAspectConfig()
{
DefaultAspectsConfigSection config = LoadConfigSection();
var initializators = new List<Func<Aspect>>();
if(config != null && !config.DefaultAspects.IsNullOrEmpty())
{
foreach(DefaultAspect defaultAspectInfo in config.DefaultAspects)
{
Type aspectType = defaultAspectInfo.Type;
string constructorParams = defaultAspectInfo.ConstructorParameters;
List<string> parms = new List<string>();
if(!constructorParams.IsBlank())
parms.Add(constructorParams);
try
{
object[] constructorArgs = parms.Cast<object>().ToArray();
Func<object> rawActivator = aspectType.GetFastActivatorWithEmbeddedArgs(constructorArgs);
Func<Aspect> activator = () => (Aspect)rawActivator();
initializators.Add(activator);
}
catch(Exception ex)
{
throw new Exception("Failed to create activators for the default set of aspects from .config file. See inner exception information.", ex);
}
}
}
return initializators;
}