Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2761 for trunk


Ignore:
Timestamp:
02/08/10 15:35:20 (14 years ago)
Author:
mkommend
Message:

improved MainForm as suggested by FxCop (ticket #857)

Location:
trunk/sources
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/MainForm.cs

    r2723 r2761  
    287287      }
    288288
    289       this.AdditionalCreationOfGUIElements();
    290     }
    291 
    292     protected virtual void AdditionalCreationOfGUIElements() {
     289      this.AdditionalCreationOfGuiElements();
     290    }
     291
     292    protected virtual void AdditionalCreationOfGuiElements() {
    293293    }
    294294
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/MultipleDocumentMainForm.cs

    r2696 r2761  
    4141    }
    4242
    43     protected override void AdditionalCreationOfGUIElements() {
    44       base.AdditionalCreationOfGUIElements();
     43    protected override void AdditionalCreationOfGuiElements() {
     44      base.AdditionalCreationOfGuiElements();
    4545      ToolStripMenuItem window = new ToolStripMenuItem("Windows");
    4646      this.menuStrip.MdiWindowListItem = window;
  • trunk/sources/HeuristicLab.MainForm/3.2/ContentAttribute.cs

    r2724 r2761  
    2424using System.Linq;
    2525using System.Text;
     26using System.Reflection;
    2627
    2728namespace HeuristicLab.MainForm {
    2829  [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
    29   public class ContentAttribute : Attribute {
    30     private Type type;
    31     public ContentAttribute(Type type) {
    32       this.type = type;
     30  public sealed class ContentAttribute : Attribute {
     31    public ContentAttribute(Type contentType) {
     32      this.contentType = contentType;
    3333    }
    3434
    35     public ContentAttribute(Type type, bool isDefaultView)
    36       : this(type) {
     35    public ContentAttribute(Type contentType, bool isDefaultView)
     36      : this(contentType) {
    3737      this.isDefaultView = isDefaultView;
    3838    }
     
    4444    }
    4545
    46     public static bool HasContentAttribute(Type viewType) {
     46    private Type contentType;
     47    public Type ContentType {
     48      get { return this.contentType; }
     49    }
     50
     51    public static bool HasContentAttribute(MemberInfo viewType) {
    4752      ContentAttribute[] attributes = (ContentAttribute[])viewType.GetCustomAttributes(typeof(ContentAttribute), false);
    4853      return attributes.Length != 0;
    4954    }
    5055
    51     public static bool CanViewType(Type viewType, Type content) {
     56    public static bool CanViewType(MemberInfo viewType, Type content) {
    5257      ContentAttribute[] attributes = (ContentAttribute[])viewType.GetCustomAttributes(typeof(ContentAttribute), false);
    53       return attributes.Any(a => content.IsAssignableTo(a.type));
     58      return attributes.Any(a => content.IsAssignableTo(a.contentType));
    5459    }
    5560
     
    5863      return from a in attributes
    5964             where a.isDefaultView
    60              select a.type;
     65             select a.contentType;
    6166    }
    6267
     
    6469      ContentAttribute[] attributes = (ContentAttribute[])viewType.GetCustomAttributes(typeof(ContentAttribute), false);
    6570      return from a in attributes
    66              select a.type;
     71             select a.contentType;
    6772    }
    6873  }
  • trunk/sources/HeuristicLab.MainForm/3.2/Interfaces/IPositionableUserInterfaceItem.cs

    r2696 r2761  
    2626
    2727namespace HeuristicLab.MainForm {
    28   public interface IPositionableUserInterfaceItem :IUserInterfaceItem {
     28  public interface IPositionableUserInterfaceItem : IUserInterfaceItem {
    2929    int Position { get; }
    3030    IEnumerable<string> Structure { get; }
  • trunk/sources/HeuristicLab.MainForm/3.2/MainFormManager.cs

    r2726 r2761  
    2828
    2929namespace HeuristicLab.MainForm {
    30   class StringDict<T> : Dictionary<string, T> {
    31   }
    3230  public static class MainFormManager {
    3331    private static object locker;
     
    3836    static MainFormManager() {
    3937      locker = new object();
     38      mainform = null;
    4039      views = new HashSet<Type>();
    4140      defaultViews = new Dictionary<Type, Type>();
    4241    }
    4342
    44     public static void RegisterMainForm(IMainForm mainform) {
     43    public static void RegisterMainForm(IMainForm mainForm) {
    4544      lock (locker) {
    4645        if (MainFormManager.mainform != null)
    4746          throw new ArgumentException("A mainform was already associated with the mainform manager.");
    48         if (mainform == null)
     47        if (mainForm == null)
    4948          throw new ArgumentException("Could not associate null as a mainform in the mainform manager.");
    5049
    51         MainFormManager.mainform = mainform;
     50        MainFormManager.mainform = mainForm;
    5251        IEnumerable<Type> types =
    5352          from t in ApplicationManager.Manager.GetTypes(typeof(IView))
     
    8685    }
    8786
    88     public static bool ViewCanViewObject(IView view, object o) {
    89       return ContentAttribute.CanViewType(view.GetType(), o.GetType());
     87    public static bool ViewCanViewObject(IView view, object content) {
     88      return ContentAttribute.CanViewType(view.GetType(), content.GetType());
    9089    }
    9190
     
    113112      //more than one default view for implemented interfaces are found
    114113      if (temp.Count > 1)
    115         throw new Exception("Could not determine which is the default view for type " + contentType.ToString() + ". Because more than one implemented interfaces have a default view.");
     114        throw new InvalidOperationException("Could not determine which is the default view for type " + contentType.ToString() + ". Because more than one implemented interfaces have a default view.");
    116115      return null;
    117116    }
    118117
    119     public static IView CreateDefaultView(object objectToView) {
    120       Type t = GetDefaultViewType(objectToView.GetType());
     118    public static IView CreateDefaultView(object content) {
     119      Type t = GetDefaultViewType(content.GetType());
    121120      if (t == null)
    122121        return null;
    123122
    124       return (IView)Activator.CreateInstance(t, objectToView);
     123      return (IView)Activator.CreateInstance(t, content);
    125124    }
    126125
     
    134133    }
    135134
    136     public static IView CreateView(Type viewType, object objectToView) {
     135    public static IView CreateView(Type viewType, object content) {
    137136      if (!typeof(IView).IsAssignableFrom(viewType))
    138137        throw new ArgumentException("View can not be created becaues given type " + viewType.ToString() + " is not of type IView.");
     
    140139        throw new ArgumentException("View can not be created becaues given type " + viewType.ToString() + " is a generic type definition.");
    141140
    142       return (IView)Activator.CreateInstance(viewType, objectToView);
     141      return (IView)Activator.CreateInstance(viewType, content);
    143142    }
    144143
  • trunk/sources/HeuristicLab.MainForm/3.2/TypeExtension.cs

    r2724 r2761  
    7878      return true;
    7979    }
    80 
    81     internal static Type[] ExtractGenericTypeArguments(this Type type, Type other) {
    82       Type[] types = new Type[0];
    83       return types;
    84     }
    8580  }
    8681}
Note: See TracChangeset for help on using the changeset viewer.