public static void Compose(Action <ExtensionConfig> configure) { var config = new ExtensionConfig(); if (configure != null) { configure(config); } var imports = new List <Lazy <IExtension, IExtensionMeta> >(); foreach (var extension in config.Extensions) { var ext = extension; Func <IExtension> func = () => { return(ext); }; var info = new ExtensionMeta(); foreach (var attr in ext.GetType().GetCustomAttributes <ExportMetadataAttribute>()) { if (attr.Name == "InternalId") { info.InternalId = (string)attr.Value; } else if (attr.Name == "Name") { info.Name = (string)attr.Value; } else if (attr.Name == "ResourceType") { info.ResourceType = (Type)attr.Value; } else if (attr.Name == "Type") { info.Type = (ExtensionType)attr.Value; } } imports.Add(new Lazy <IExtension, IExtensionMeta>(func, info)); } Current.Extensions = imports; Current.PageTypes = config.PageTypes; Current.PostTypes = config.PostTypes; Current.OnImportsSatisfied(); }
public static void Compose(Action<ExtensionConfig> configure) { var config = new ExtensionConfig(); if (configure != null) configure(config); var imports = new List<Lazy<IExtension, IExtensionMeta>>(); foreach (var extension in config.Extensions) { var ext = extension; Func<IExtension> func = () => { return ext; }; var info = new ExtensionMeta(); foreach (var attr in ext.GetType().GetCustomAttributes<ExportMetadataAttribute>()) { if (attr.Name == "InternalId") { info.InternalId = (string)attr.Value; } else if (attr.Name == "Name") { info.Name = (string)attr.Value; } else if (attr.Name == "ResourceType") { info.ResourceType = (Type)attr.Value; } else if (attr.Name == "Type") { info.Type = (ExtensionType)attr.Value; } } imports.Add(new Lazy<IExtension, IExtensionMeta>(func, info)); } Current.Extensions = imports; Current.PageTypes = config.PageTypes; Current.PostTypes = config.PostTypes; Current.OnImportsSatisfied(); }