public static void RegisterAllModules(this IModuleFactory moduleFactory, Assembly assembly) { var foundTypes = assembly .GetTypes() .Where(t => t.GetCustomAttribute <ModuleAttribute>() != null) .ToList(); foreach (var type in foundTypes) { ModuleAttribute attribute = type.GetCustomAttribute <ModuleAttribute>(); var description = FillDescriptionFromAttribute(type, attribute); moduleFactory.Register(description.ModuleType, description, (runtime, s) => (IModule)s.GetInstance(type), type); } var typeAliases = assembly .GetTypes() .Where(t => t.GetCustomAttribute <ModuleTypeAliasAttribute>() != null) .ToList(); foreach (var type in typeAliases) { ModuleAttribute moduleAttribute = type.GetCustomAttribute <ModuleAttribute>(); ModuleTypeAliasAttribute aliasAttribute = type.GetCustomAttribute <ModuleTypeAliasAttribute>(); if (moduleAttribute == null || aliasAttribute == null) { continue; } moduleFactory.RegisterAlias(aliasAttribute.AliasType, moduleAttribute.ModuleType, aliasAttribute.IncludeInCatalog); } }
public override void Register(IModuleFactory factory) { factory.Register(moduleType, new ModuleDescription { ModuleType = moduleType, HelpText = description }, (runtime, s) => (IModule) new BinaryOperation(runtime, moduleType, operation, resultPinId, operand1PinId, operand2PinId), null); }
public static void RegisterWithType(this IModuleFactory factory, Type type, ModuleDescription description) { factory.Register(type.FullName, description, (runtime, s) => (IModule)s.GetInstance(type), type); }