/// <summary> /// Make a dialog from the module type name and run it to configure an /// existing module. /// </summary> /// <param name="moduleTypeName">Module type name to find the proper /// dialog type for it</param> /// <param name="existingModule">Existing module to be configured /// </param> /// <returns>Configured module</returns> public static Module configureModule( string moduleTypeName, Module existingModule) { if (moduleTypeName == null) { return null; } ModuleRegistry moduleRegistry = ModuleRegistry.Instance; Type moduleType = moduleRegistry.getModuleType(moduleTypeName); Type dialogType = moduleRegistry.getDialogType(moduleTypeName); if ((moduleType == null) || (dialogType == null)) { return null; } ModuleDialog dialog = null; System.Reflection.ConstructorInfo ci; if (existingModule != null) { ci = dialogType.GetConstructor(new Type[] { moduleType }); if (ci != null) { dialog = ci.Invoke(new object[] { existingModule }) as ModuleDialog; } } else { ci = dialogType.GetConstructor(new Type[0]); if (ci != null) { dialog = ci.Invoke(null) as ModuleDialog; } } if (dialog != null) { return dialog.runConfiguration(); } return null; }
/// <summary> /// Create a new module dialog with an existing module. /// </summary> /// <param name="module"></param> protected ModuleDialog(Module module) { originalModule = module; modifiedModule = (Module)module.deepCopy(); string moduleName = module.GetType().Name; ModuleAttribute attribute = ModuleRegistry.Instance.getModuleAttribute(moduleName); Title = (attribute != null) ? attribute.TypeName : moduleName; Modal = true; AddButton("OK", ResponseType.Ok); AddButton("Cancel", ResponseType.Cancel); }