- Timestamp:
- 02/08/10 15:35:20 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.MainForm/3.2/ContentAttribute.cs
r2724 r2761 24 24 using System.Linq; 25 25 using System.Text; 26 using System.Reflection; 26 27 27 28 namespace HeuristicLab.MainForm { 28 29 [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; 33 33 } 34 34 35 public ContentAttribute(Type type, bool isDefaultView)36 : this( type) {35 public ContentAttribute(Type contentType, bool isDefaultView) 36 : this(contentType) { 37 37 this.isDefaultView = isDefaultView; 38 38 } … … 44 44 } 45 45 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) { 47 52 ContentAttribute[] attributes = (ContentAttribute[])viewType.GetCustomAttributes(typeof(ContentAttribute), false); 48 53 return attributes.Length != 0; 49 54 } 50 55 51 public static bool CanViewType( TypeviewType, Type content) {56 public static bool CanViewType(MemberInfo viewType, Type content) { 52 57 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)); 54 59 } 55 60 … … 58 63 return from a in attributes 59 64 where a.isDefaultView 60 select a. type;65 select a.contentType; 61 66 } 62 67 … … 64 69 ContentAttribute[] attributes = (ContentAttribute[])viewType.GetCustomAttributes(typeof(ContentAttribute), false); 65 70 return from a in attributes 66 select a. type;71 select a.contentType; 67 72 } 68 73 }
Note: See TracChangeset
for help on using the changeset viewer.