internal static bool LoadPluginsFromAssembly(Assembly assembly) { Type[] typesFromAsm = assembly.GetTypes(); DPluginDefinition definition = null; bool foundPlugin = false; foreach (Type type in typesFromAsm) { Attribute attribute = type.GetCustomAttribute(typeof(DPluginInformation), true); if (attribute != null) { DPluginInformation pluginInformation = (DPluginInformation)attribute; if (type.BaseType == typeof(DPlugin)) { // Valid DAE Plugin! foundPlugin = true; definition = new DPluginDefinition(pluginInformation, type); Logger.Log($"Loaded plugin from assembly '{assembly.FullName}':\n\tName: {pluginInformation.name}\n\tAuthor: {pluginInformation.author}\n\tDescription: {pluginInformation.description}"); break; } } } if (foundPlugin && definition != null) { foreach (Type type in typesFromAsm) { Attribute attribute = type.GetCustomAttribute(typeof(DCustomComponent), true); if (attribute != null) { DCustomComponent customComponent = (DCustomComponent)attribute; if (type.IsSubclassOf(typeof(Component))) { DCustomComponentDefinition componentDefinition = new DCustomComponentDefinition(customComponent, type); definition.customComponents.Add(componentDefinition); Logger.Log($"Loaded custom component from assembly '{assembly.FullName}':\n\tActual Name: {customComponent.name}\n\tUsable Name: {definition.information.name}.{customComponent.name}"); } } } } if (definition != null) { definitions.Add(definition); return(true); } return(false); }
public DCustomComponentDefinition(DCustomComponent information, Type type) { this.information = information; this.type = type; }