Free cookie consent management tool by TermsFeed Policy Generator

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

improved MainForm as suggested by FxCop (ticket #857)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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  }
Note: See TracChangeset for help on using the changeset viewer.