/// <summary> /// 返回枚举项的描述信息。 /// </summary> /// <param name="value">要获取描述信息的枚举项。</param> /// <returns>枚举想的描述信息。</returns> public static string GetDescription(this Enum value, bool isTop = false) { Type enumType = value.GetType(); DescriptionAttribute attr = null; if (isTop) { attr = (DescriptionAttribute)Attribute.GetCustomAttribute(enumType, typeof(DescriptionAttribute)); } else { // 获取枚举常数名称。 string name = Enum.GetName(enumType, value); if (name != null) { // 获取枚举字段。 FieldInfo fieldInfo = enumType.GetField(name); if (fieldInfo != null) { // 获取描述的属性。 attr = Attribute.GetCustomAttribute(fieldInfo, typeof(DescriptionAttribute), false) as DescriptionAttribute; } } } if (attr != null && !string.IsNullOrEmpty(attr.ToString())) //.Description; //Exception { return(attr.ToString()); //.Description; } else { return(string.Empty); } }
/// <summary> /// Create and return a new Output object for member /// </summary> /// <param name="member">The member</param> /// <param name="memberType">The name of the type.</param> /// <param name="writable">Is writable?</param> private static ModelDoc.Output DocumentOutput(MemberInfo member, Type memberType, bool writable) { ModelDoc.Output output = new ModelDoc.Output(); output.Name = member.Name; if (memberType.IsGenericType && memberType.GetInterface("IList") != null) { output.TypeName = "List<" + memberType.GenericTypeArguments[0].Name + ">"; } else { output.TypeName = memberType.Name; } UnitsAttribute units = member.GetCustomAttribute <UnitsAttribute>(); if (units != null) { output.Units = units.ToString(); } DescriptionAttribute description = member.GetCustomAttribute <DescriptionAttribute>(); if (description != null) { output.Description = description.ToString(); } output.IsWritable = writable; output.IsField = member is FieldInfo; return(output); }
/// <summary> /// Attach the Manager model and ManagerView to this presenter. /// </summary> /// <param name="model">The model</param> /// <param name="view">The view to attach</param> /// <param name="presenter">The explorer presenter being used</param> public void Attach(object model, object view, ExplorerPresenter presenter) { manager = model as Manager; managerView = view as IManagerView; explorerPresenter = presenter; intellisense = new IntellisensePresenter(managerView as ViewBase); intellisense.ItemSelected += OnIntellisenseItemSelected; scriptModel = manager.Children.FirstOrDefault(); // See if manager script has a description attribute on it's class. if (scriptModel != null) { DescriptionAttribute descriptionName = ReflectionUtilities.GetAttribute(scriptModel.GetType(), typeof(DescriptionAttribute), false) as DescriptionAttribute; if (descriptionName != null) { explorerPresenter.ShowDescriptionInRightHandPanel(descriptionName.ToString()); } } propertyPresenter.Attach(scriptModel, managerView.GridView, presenter); managerView.Editor.Mode = EditorType.ManagerScript; managerView.Editor.Text = manager.Code; managerView.Editor.ContextItemsNeeded += OnNeedVariableNames; managerView.Editor.LeaveEditor += OnEditorLeave; managerView.Editor.AddContextSeparator(); managerView.Editor.AddContextActionWithAccel("Test compile", OnDoCompile, "Ctrl+T"); managerView.Editor.AddContextActionWithAccel("Reformat", OnDoReformat, "Ctrl+R"); managerView.Editor.Location = manager.Location; managerView.TabIndex = manager.ActiveTabIndex; presenter.CommandHistory.ModelChanged += CommandHistory_ModelChanged; }
private static void DocumentVariables(StreamWriter OutputFile, Model parentModel) { OutputFile.WriteLine(Header("Public properties", 3, null)); OutputFile.WriteLine("<table style=\"text-align: left; valign: top;\" border=\"1\" >"); OutputFile.WriteLine("<th>Name</th><th>Units</th><th>Data type</th><th>Description</th>"); foreach (PropertyInfo property in parentModel.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)) { string unitsString = string.Empty; UnitsAttribute units = ReflectionUtilities.GetAttribute(property, typeof(UnitsAttribute), false) as UnitsAttribute; if (units != null) { unitsString = units.ToString(); } string descriptionString = string.Empty; DescriptionAttribute description = ReflectionUtilities.GetAttribute(property, typeof(DescriptionAttribute), false) as DescriptionAttribute; if (description != null) { descriptionString = description.ToString(); } OutputFile.Write("<tr>"); OutputFile.Write("<td id=\"properties\" >" + property.Name + "</td>"); OutputFile.Write("<td id=\"properties\" >" + unitsString + "</td>"); OutputFile.Write("<td id=\"properties\" >" + property.PropertyType.Name + "</td>"); OutputFile.Write("<td id=\"properties\" >" + descriptionString + "</td>"); OutputFile.WriteLine("</tr>"); } OutputFile.WriteLine("</table>"); }
/// <summary>Display a view on the right hand panel in view.</summary> public void ShowRightHandPanel() { if (this.view.Tree.SelectedNode != string.Empty) { object model = this.ApsimXFile.FindByPath(this.view.Tree.SelectedNode)?.Value; if (model != null) { ViewNameAttribute viewName = ReflectionUtilities.GetAttribute(model.GetType(), typeof(ViewNameAttribute), false) as ViewNameAttribute; PresenterNameAttribute presenterName = ReflectionUtilities.GetAttribute(model.GetType(), typeof(PresenterNameAttribute), false) as PresenterNameAttribute; DescriptionAttribute descriptionName = ReflectionUtilities.GetAttribute(model.GetType(), typeof(DescriptionAttribute), false) as DescriptionAttribute; if (descriptionName != null && model.GetType().Namespace.Contains("CLEM")) { viewName = new ViewNameAttribute("UserInterface.Views.ModelDetailsWrapperView"); presenterName = new PresenterNameAttribute("UserInterface.Presenters.ModelDetailsWrapperPresenter"); } if (Configuration.Settings.UseNewPropertyPresenter && presenterName != null) { if (presenterName.ToString().Contains(".PropertyPresenter")) { presenterName = new PresenterNameAttribute("UserInterface.Presenters.SimplePropertyPresenter"); viewName = new ViewNameAttribute("UserInterface.Views.PropertyView"); } else if (presenterName.ToString().Contains(".BiomassRemovalPresenter")) { presenterName = new PresenterNameAttribute("UserInterface.Presenters.CompositePropertyPresenter"); viewName = new ViewNameAttribute("UserInterface.Views.PropertyView"); } } // if a clem model ignore the newly added description box that is handled by CLEM wrapper if (!model.GetType().Namespace.Contains("CLEM")) { ShowDescriptionInRightHandPanel(descriptionName?.ToString()); } if (viewName != null && viewName.ToString().Contains(".glade")) { ShowInRightHandPanel(model, newView: new ViewBase(view as ViewBase, viewName.ToString()), presenter: Assembly.GetExecutingAssembly().CreateInstance(presenterName.ToString()) as IPresenter); } else if (viewName != null && presenterName != null) { ShowInRightHandPanel(model, viewName.ToString(), presenterName.ToString()); } else { var view = new MarkdownView(this.view as ViewBase); var presenter = new DocumentationPresenter(); ShowInRightHandPanel(model, view, presenter); } } } }
private static string getDescriptionFromEnumValue(Enum value) { DescriptionAttribute description = value.GetType(). GetField(value.ToString()). GetCustomAttributes(typeof(DescriptionAttribute), false). SingleOrDefault() as DescriptionAttribute; return(description == null?value.ToString() : description.ToString()); }
/// <summary> /// 读取 <see cref="System.Enum"/> 标记 <see cref="System.ComponentModel.DescriptionAttribute"/> 的值 /// </summary> /// <param name="value">原始 <see cref="System.Enum"/> 值</param> /// <returns></returns> public static string GetDescription(this System.Enum value) { if (value == null) { return(string.Empty); } FieldInfo fieldInfo = value.GetType().GetField(value.ToString()); DescriptionAttribute attribute = fieldInfo.GetCustomAttribute <DescriptionAttribute>(false); return(attribute.ToString()); }
/// <summary> /// Attach the Manager model and ManagerView to this presenter. /// </summary> /// <param name="model">The model</param> /// <param name="view">The view to attach</param> /// <param name="presenter">The explorer presenter being used</param> public void Attach(object model, object view, ExplorerPresenter presenter) { manager = model as Manager; managerView = view as IManagerView; explorerPresenter = presenter; intellisense = new IntellisensePresenter(managerView as ViewBase); intellisense.ItemSelected += OnIntellisenseItemSelected; scriptModel = manager.Children.FirstOrDefault(); // See if manager script has a description attribute on it's class. if (scriptModel != null) { DescriptionAttribute descriptionName = ReflectionUtilities.GetAttribute(scriptModel.GetType(), typeof(DescriptionAttribute), false) as DescriptionAttribute; if (descriptionName != null) { explorerPresenter.ShowDescriptionInRightHandPanel(descriptionName.ToString()); } } if (Configuration.Settings.UseNewPropertyPresenter) { propertyPresenter = new SimplePropertyPresenter(); } else { propertyPresenter = new PropertyPresenter(); } try { propertyPresenter.Attach(scriptModel, managerView.PropertyEditor, presenter); } catch (Exception err) { explorerPresenter.MainPresenter.ShowError(err); } managerView.Editor.Mode = EditorType.ManagerScript; managerView.Editor.Text = manager.Code; #if NETFRAMEWORK // In gtk3 builds, the gtksourceview completion infrastructure // handles all of the completion functionality internally. managerView.Editor.ContextItemsNeeded += OnNeedVariableNames; #endif managerView.Editor.LeaveEditor += OnEditorLeave; managerView.Editor.AddContextSeparator(); managerView.Editor.AddContextActionWithAccel("Test compile", OnDoCompile, "Ctrl+T"); managerView.Editor.AddContextActionWithAccel("Reformat", OnDoReformat, "Ctrl+R"); managerView.Editor.Location = manager.Location; managerView.TabIndex = manager.ActiveTabIndex; presenter.CommandHistory.ModelChanged += CommandHistory_ModelChanged; }
private static void WriteDescriptionForTypeName(StreamWriter OutputFile, XmlNode node, Model parentModel) { if (parentModel != null) { PropertyInfo property = parentModel.GetType().GetProperty(XmlUtilities.Value(node, "Name")); if (property != null) { UnitsAttribute units = ReflectionUtilities.GetAttribute(property, typeof(UnitsAttribute), false) as UnitsAttribute; if (units != null) { OutputFile.WriteLine("<p>Units: " + units.ToString() + "</p>"); } DescriptionAttribute description = ReflectionUtilities.GetAttribute(property, typeof(DescriptionAttribute), false) as DescriptionAttribute; if (description != null) { OutputFile.WriteLine("<p>" + description.ToString() + "</p>"); } } else { FieldInfo field = parentModel.GetType().GetField(XmlUtilities.Value(node, "Name"), BindingFlags.NonPublic | BindingFlags.Instance); if (field != null) { UnitsAttribute units = ReflectionUtilities.GetAttribute(field, typeof(UnitsAttribute), false) as UnitsAttribute; if (units != null) { OutputFile.WriteLine("<p>Units: " + units.ToString() + "</p>"); } DescriptionAttribute description = ReflectionUtilities.GetAttribute(field, typeof(DescriptionAttribute), false) as DescriptionAttribute; if (description != null) { OutputFile.WriteLine("<p>" + description.ToString() + "</p>"); } } } } Type[] t = ReflectionUtilities.GetTypeWithoutNameSpace(node.Name, Assembly.GetExecutingAssembly()); if (t.Length == 1) { DescriptionAttribute description = ReflectionUtilities.GetAttribute(t[0], typeof(DescriptionAttribute), false) as DescriptionAttribute; if (description != null) { OutputFile.WriteLine("<p>" + description.ToString() + "</p>"); } } }
public void Attach(object model, object view, ExplorerPresenter explorerPresenter) { this.ApsimXFile = model as Simulations; this.ExplorerPresenter = explorerPresenter; this.View = view as IModelDetailsWrapperView; if (model != null) { ViewNameAttribute viewName = ReflectionUtilities.GetAttribute(model.GetType(), typeof(ViewNameAttribute), false) as ViewNameAttribute; PresenterNameAttribute presenterName = ReflectionUtilities.GetAttribute(model.GetType(), typeof(PresenterNameAttribute), false) as PresenterNameAttribute; View.ModelTypeText = model.GetType().ToString().Substring("Models.".Length); DescriptionAttribute descAtt = ReflectionUtilities.GetAttribute(model.GetType(), typeof(DescriptionAttribute), false) as DescriptionAttribute; if (descAtt != null) { View.ModelDescriptionText = descAtt.ToString(); } else { View.ModelDescriptionText = ""; } // Set CLEM specific colours for title if (View.ModelTypeText.Contains(".Resources.")) { View.ModelTypeTextColour = "996633"; } else if (View.ModelTypeText.Contains("Activities.")) { View.ModelTypeTextColour = "009999"; } HelpUriAttribute helpAtt = ReflectionUtilities.GetAttribute(model.GetType(), typeof(HelpUriAttribute), false) as HelpUriAttribute; View.ModelHelpURL = ""; if (helpAtt != null) { View.ModelHelpURL = helpAtt.ToString(); } if (viewName != null && presenterName != null) { ShowInLowerPanel(model, viewName.ToString(), presenterName.ToString()); } } }
/// <summary> /// Create and return a new Link object for member /// </summary> /// <param name="field">The member</param> /// <param name="model">Model with the link</param> private static ModelDoc.Link DocumentLink(FieldInfo field, IModel model) { ModelDoc.Link link = new ModelDoc.Link(); link.Name = field.Name; if (field.FieldType.IsGenericType && field.FieldType.GetInterface("IList") != null) { link.TypeName = "List<" + field.FieldType.GenericTypeArguments[0].Name + ">"; } else { link.TypeName = field.FieldType.Name; } UnitsAttribute units = field.GetCustomAttribute <UnitsAttribute>(); if (units != null) { link.Units = units.ToString(); } DescriptionAttribute description = field.GetCustomAttribute <DescriptionAttribute>(); if (description != null) { link.Description = description.ToString(); } LinkAttribute linkAtt = field.GetCustomAttribute <LinkAttribute>(); link.IsOptional = linkAtt.IsOptional; object linkedObject = field.GetValue(model); if (linkedObject != null) { if (linkedObject is IModel) { link.LinkedModelName = Apsim.FullPath(linkedObject as IModel); } else { } } return(link); }
public void Attach(object model, object view, ExplorerPresenter explorerPresenter) { this.ExplorerPresenter = explorerPresenter; this.View = view as IWFMasterView; if (model != null) { ViewNameAttribute viewName = ReflectionUtilities.GetAttribute(model.GetType(), typeof(ViewNameAttribute), false) as ViewNameAttribute; PresenterNameAttribute presenterName = ReflectionUtilities.GetAttribute(model.GetType(), typeof(PresenterNameAttribute), false) as PresenterNameAttribute; View.ModelTypeText = model.GetType().ToString().Substring("Models.WholeFarm.".Length); DescriptionAttribute descAtt = ReflectionUtilities.GetAttribute(model.GetType(), typeof(DescriptionAttribute), false) as DescriptionAttribute; if (descAtt != null) { View.ModelDescriptionText = descAtt.ToString(); } else { View.ModelDescriptionText = ""; } View.ModelHelpURL = "http://CLEMHelp.csiro.au/" + View.ModelTypeText + ".html"; if (View.ModelTypeText.Contains("Resources.")) { View.ModelTypeTextColour = Color.FromArgb(153, 102, 51); } else if (View.ModelTypeText.Contains("Activities.")) { View.ModelTypeTextColour = Color.FromArgb(0, 153, 153); } else { View.ModelTypeTextColour = Color.Black; } if (viewName != null && presenterName != null) { ShowInLowerPanel(model, viewName.ToString(), presenterName.ToString()); } } }
public static string GetDescription(this Enum value) { Type type = value.GetType(); string name = Enum.GetName(type, value); if (name != null) { FieldInfo field = type.GetField(name); if (field != null) { DescriptionAttribute attr = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute; if (attr != null) { return(attr.ToString()); } } } return(null); }
/// <summary>Display a view on the right hand panel in view.</summary> public void ShowRightHandPanel() { try { if (this.view.Tree.SelectedNode != string.Empty) { object model = Apsim.Get(this.ApsimXFile, this.view.Tree.SelectedNode); if (model != null) { ViewNameAttribute viewName = ReflectionUtilities.GetAttribute(model.GetType(), typeof(ViewNameAttribute), false) as ViewNameAttribute; PresenterNameAttribute presenterName = ReflectionUtilities.GetAttribute(model.GetType(), typeof(PresenterNameAttribute), false) as PresenterNameAttribute; DescriptionAttribute descriptionName = ReflectionUtilities.GetAttribute(model.GetType(), typeof(DescriptionAttribute), false) as DescriptionAttribute; if (descriptionName != null && model.GetType().Namespace.Contains("CLEM")) { viewName = new ViewNameAttribute("UserInterface.Views.ModelDetailsWrapperView"); presenterName = new PresenterNameAttribute("UserInterface.Presenters.ModelDetailsWrapperPresenter"); } if (viewName == null && presenterName == null) { viewName = new ViewNameAttribute("UserInterface.Views.HTMLView"); presenterName = new PresenterNameAttribute("UserInterface.Presenters.GenericPresenter"); } ShowDescriptionInRightHandPanel(descriptionName?.ToString()); if (viewName != null && presenterName != null) { ShowInRightHandPanel(model, viewName.ToString(), presenterName.ToString()); } } } } catch (Exception err) { MainPresenter.ShowError(err); } }
/// <summary>Display a view on the right hand panel in view.</summary> public void ShowRightHandPanel() { if (this.view.Tree.SelectedNode != string.Empty) { object model = Apsim.Get(this.ApsimXFile, this.view.Tree.SelectedNode); if (model != null) { ViewNameAttribute viewName = ReflectionUtilities.GetAttribute(model.GetType(), typeof(ViewNameAttribute), false) as ViewNameAttribute; PresenterNameAttribute presenterName = ReflectionUtilities.GetAttribute(model.GetType(), typeof(PresenterNameAttribute), false) as PresenterNameAttribute; DescriptionAttribute descriptionName = ReflectionUtilities.GetAttribute(model.GetType(), typeof(DescriptionAttribute), false) as DescriptionAttribute; if (descriptionName != null && model.GetType().Namespace.Contains("CLEM")) { viewName = new ViewNameAttribute("UserInterface.Views.ModelDetailsWrapperView"); presenterName = new PresenterNameAttribute("UserInterface.Presenters.ModelDetailsWrapperPresenter"); } // if a clem model ignore the newly added description box that is handled by CLEM wrapper if (!model.GetType().Namespace.Contains("CLEM")) { ShowDescriptionInRightHandPanel(descriptionName?.ToString()); } if (viewName != null && viewName.ToString().Contains(".glade")) { ShowInRightHandPanel(model, newView: new ViewBase(view as ViewBase, viewName.ToString()), presenter: Assembly.GetExecutingAssembly().CreateInstance(presenterName.ToString()) as IPresenter); } else if (viewName != null && presenterName != null) { ShowInRightHandPanel(model, viewName.ToString(), presenterName.ToString()); } } } }
/// <summary> /// The view is asking for variable names for its intellisense. /// </summary> /// <param name="atype">Data type for which we want completion options.</param> /// <param name="properties">If true, property suggestions will be generated.</param> /// <param name="methods">If true, method suggestions will be generated.</param> /// <param name="events">If true, event suggestions will be generated.</param> /// <returns>List of completion options.</returns> public static List <ContextItem> ExamineTypeForContextItems(Type atype, bool properties, bool methods, bool events) { List <ContextItem> allItems = new List <ContextItem>(); // find the properties and methods if (atype != null) { if (properties) { foreach (PropertyInfo property in atype.GetProperties(BindingFlags.Instance | BindingFlags.Public)) { VariableProperty var = new VariableProperty(atype, property); NeedContextItemsArgs.ContextItem item = new NeedContextItemsArgs.ContextItem(); item.Name = var.Name; item.IsProperty = true; item.IsEvent = false; item.IsWriteable = !var.IsReadOnly; item.TypeName = var.DataType.Name; item.Descr = var.Description; item.Units = var.Units; allItems.Add(item); } } if (methods) { foreach (MethodInfo method in atype.GetMethods(BindingFlags.Instance | BindingFlags.Public)) { if (!method.Name.StartsWith("get_") && !method.Name.StartsWith("set_")) { DescriptionAttribute descriptionAttribute = ReflectionUtilities.GetAttribute(atype, typeof(DescriptionAttribute), false) as DescriptionAttribute; NeedContextItemsArgs.ContextItem item = new NeedContextItemsArgs.ContextItem(); item.Name = method.Name; item.IsProperty = false; item.IsEvent = true; item.IsWriteable = false; item.TypeName = method.ReturnType.Name; if (descriptionAttribute != null) { item.Descr = descriptionAttribute.ToString(); } item.Units = string.Empty; // build a parameter string representation ParameterInfo[] allparams = method.GetParameters(); StringBuilder paramText = new StringBuilder("( "); if (allparams.Count() > 0) { for (int p = 0; p < allparams.Count(); p++) { ParameterInfo parameter = allparams[p]; paramText.Append(parameter.ParameterType.Name + " " + parameter.Name); if (p < allparams.Count() - 1) { paramText.Append(", "); } } } paramText.Append(" )"); item.ParamString = paramText.ToString(); allItems.Add(item); } } } if (events) { foreach (EventInfo evnt in atype.GetEvents(BindingFlags.Instance | BindingFlags.Public)) { NeedContextItemsArgs.ContextItem item = new NeedContextItemsArgs.ContextItem(); item.Name = evnt.Name; item.IsProperty = true; item.IsEvent = true; item.IsWriteable = false; item.TypeName = evnt.ReflectedType.Name; item.Descr = ""; item.Units = ""; allItems.Add(item); } } } allItems.Sort(delegate(ContextItem c1, ContextItem c2) { return(c1.Name.CompareTo(c2.Name)); }); return(allItems); }
public void Attach(object model, object view, ExplorerPresenter explorerPresenter) { this.ApsimXFile = model as Simulations; this.ExplorerPresenter = explorerPresenter; this.View = view as IModelDetailsWrapperView; if (model != null) { ViewNameAttribute viewName = ReflectionUtilities.GetAttribute(model.GetType(), typeof(ViewNameAttribute), false) as ViewNameAttribute; PresenterNameAttribute presenterName = ReflectionUtilities.GetAttribute(model.GetType(), typeof(PresenterNameAttribute), false) as PresenterNameAttribute; View.ModelTypeText = model.GetType().ToString().Substring("Models.".Length); DescriptionAttribute descAtt = ReflectionUtilities.GetAttribute(model.GetType(), typeof(DescriptionAttribute), false) as DescriptionAttribute; if (descAtt != null) { View.ModelDescriptionText = descAtt.ToString(); } else { View.ModelDescriptionText = ""; } // Set CLEM specific colours for title if (View.ModelTypeText.Contains(".Resources.")) { View.ModelTypeTextColour = "996633"; } else if (View.ModelTypeText.Contains(".Activities.LabourRequirement")) { View.ModelTypeTextColour = "cc33cc"; } else if (View.ModelTypeText.Contains(".Activities.")) { View.ModelTypeTextColour = "009999"; } else if (View.ModelTypeText.Contains(".Groupings.")) { View.ModelTypeTextColour = "cc33cc"; } else if (View.ModelTypeText.Contains(".File")) { View.ModelTypeTextColour = "008000"; } HelpUriAttribute helpAtt = ReflectionUtilities.GetAttribute(model.GetType(), typeof(HelpUriAttribute), false) as HelpUriAttribute; View.ModelHelpURL = ""; if (helpAtt != null) { View.ModelHelpURL = helpAtt.ToString(); } var vs = ReflectionUtilities.GetAttributes(model.GetType(), typeof(VersionAttribute), false); if (vs.Count() > 0) { VersionAttribute verAtt = vs.ToList <Attribute>().Last() as VersionAttribute; if (verAtt != null) { string v = "Version "; v += verAtt.ToString(); View.ModelVersionText = v; } else { View.ModelVersionText = ""; } } if (viewName != null && presenterName != null) { // if model CLEMModel if (model.GetType().IsSubclassOf(typeof(CLEMModel)) || model is ZoneCLEM) { ShowInLowerPanel(model, "UserInterface.Views.CLEMView", "UserInterface.Presenters.CLEMPresenter"); } else { ShowInLowerPanel(model, viewName.ToString(), presenterName.ToString()); } } } }
public void Attach(object model, object view, ExplorerPresenter explorerPresenter) { this.ApsimXFile = model as Simulations; this.explorerPresenter = explorerPresenter; this.view = view as IModelDetailsWrapperView; if (model != null) { ViewNameAttribute viewName = ReflectionUtilities.GetAttribute(model.GetType(), typeof(ViewNameAttribute), false) as ViewNameAttribute; PresenterNameAttribute presenterName = ReflectionUtilities.GetAttribute(model.GetType(), typeof(PresenterNameAttribute), false) as PresenterNameAttribute; this.view.ModelTypeText = model.GetType().ToString().Substring("Models.".Length); DescriptionAttribute descAtt = ReflectionUtilities.GetAttribute(model.GetType(), typeof(DescriptionAttribute), false) as DescriptionAttribute; if (descAtt != null) { this.view.ModelDescriptionText = descAtt.ToString(); } else { this.view.ModelDescriptionText = ""; } // Set CLEM specific colours for title if (this.view.ModelTypeText.Contains(".Resources.")) { this.view.ModelTypeTextColour = "996633"; } else if (this.view.ModelTypeText.Contains(".Activities.LabourRequirement")) { this.view.ModelTypeTextColour = "cc33cc"; } else if (this.view.ModelTypeText.Contains(".Activities.")) { this.view.ModelTypeTextColour = "009999"; } else if (this.view.ModelTypeText.Contains(".Groupings.")) { this.view.ModelTypeTextColour = "cc33cc"; } else if (this.view.ModelTypeText.Contains(".File")) { this.view.ModelTypeTextColour = "008000"; } else if (this.view.ModelTypeText.Contains(".Market")) { this.view.ModelTypeTextColour = "1785FF"; } HelpUriAttribute helpAtt = ReflectionUtilities.GetAttribute(model.GetType(), typeof(HelpUriAttribute), false) as HelpUriAttribute; this.view.ModelHelpURL = ""; if (helpAtt != null) { this.view.ModelHelpURL = helpAtt.ToString(); } var vs = ReflectionUtilities.GetAttributes(model.GetType(), typeof(VersionAttribute), false); if (vs.Count() > 0) { VersionAttribute verAtt = vs.ToList <Attribute>().Cast <VersionAttribute>().OrderBy(a => a.ToString()).Last() as VersionAttribute; if (verAtt != null) { string v = "Version "; v += verAtt.ToString(); this.view.ModelVersionText = v; } else { this.view.ModelVersionText = ""; } } if (viewName != null && presenterName != null) { // if model CLEMModel if (model.GetType().IsSubclassOf(typeof(CLEMModel)) | model is ZoneCLEM | model is Market | model is RandomNumberGenerator) { // all CLEMModels will handle this presenter ShowInLowerPanel(model, "UserInterface.Views.CLEMView", "UserInterface.Presenters.CLEMPresenter"); } else if (typeof(ICLEMPresenter).IsAssignableFrom(Assembly.GetExecutingAssembly().GetType(presenterName.ToString()))) { // apply this if the presenter has ICLEMPresenter interface and is ready to create presenters ShowInLowerPanel(model, "UserInterface.Views.CLEMView", "UserInterface.Presenters.CLEMPresenter"); } else { ShowInLowerPanel(model, viewName.ToString(), presenterName.ToString()); } } } }