using System; using System.Reflection; using System.Windows.Forms; using Rmake.Model; using Rmake.Model.Processable.Orders; using Rmake.Framework.Logging; namespace Rmake.GUI.Editor.Orders { /// /// OrderEditorLoader の概要の説明です。 /// public class OrderEditorLoader { public static Form GetOrderEditor(Type orderType, Order order, EditingModelFactory factory) { try { Type editorType = null; Assembly assembly = Assembly.GetAssembly(typeof(OrderSelectDialog)); Type[] types = assembly.GetTypes(); foreach (Type type in types) { Object[] attributes = type.GetCustomAttributes(typeof(OrderEditorAttribute), true); foreach (Object attribute in attributes) { if (attribute is OrderEditorAttribute) { Type temp = ((OrderEditorAttribute) attribute).OrderType; if ((orderType.Equals(temp)) || (orderType.IsSubclassOf(temp))) { editorType = type; break; } } } if (editorType != null) { break; } } if (editorType != null) { if ((editorType.Equals(typeof(DoScriptOrderEditor))) || (editorType.Equals(typeof(MoveMapOrderEditor))) || (editorType.Equals(typeof(AddCharacterOrderEditor)))) { Type[] parameters = new Type[2]; parameters[0] = typeof(Order); parameters[1] = typeof(EditingModelFactory); ConstructorInfo cInfo = editorType.GetConstructor(parameters); Object[] cParams = new Object[2]; cParams[0] = order; cParams[1] = factory; return (Form)cInfo.Invoke(cParams); } else { Type[] parameters = new Type[1]; parameters[0] = typeof(Order); ConstructorInfo cInfo = editorType.GetConstructor(parameters); Object[] cParams = new Object[1]; cParams[0] = order; return (Form)cInfo.Invoke(cParams); } } } catch (Exception ex) { Logger.Fatal(ex); } return null; } } }