Changeset 2931 for trunk/sources/HeuristicLab.Core/3.3/Attributes
- Timestamp:
- 03/05/10 01:03:30 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Core/3.3/Attributes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core/3.3/Attributes/CreatableAttribute.cs
r2790 r2931 21 21 22 22 using System; 23 using System.Collections.Generic;24 using System.Text;25 23 26 24 namespace HeuristicLab.Core { -
trunk/sources/HeuristicLab.Core/3.3/Attributes/ItemAttribute.cs
r2790 r2931 21 21 22 22 using System; 23 using System.Collections.Generic; 24 using System.Text; 25 using System.Resources; 26 using System.Drawing; 23 using HeuristicLab.Common; 27 24 28 25 namespace HeuristicLab.Core { 29 26 [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] 30 27 public sealed class ItemAttribute : Attribute { 31 public string Name { get; set; } 32 public string Description { get; set; } 28 private string name; 29 public string Name { 30 get { return name; } 31 set { name = value == null ? string.Empty : value; } 32 } 33 private string description; 34 public string Description { 35 get { return description; } 36 set { description = value == null ? string.Empty : value; } 37 } 33 38 34 39 public ItemAttribute() { 35 Name = null;36 Description = null;40 Name = string.Empty; 41 Description = string.Empty; 37 42 } 38 43 public ItemAttribute(string name, string description) { … … 42 47 43 48 public static string GetName(Type type) { 44 object[] attribs = type.GetCustomAttributes(typeof(ItemAttribute), true);49 object[] attribs = type.GetCustomAttributes(typeof(ItemAttribute), false); 45 50 if (attribs.Length > 0) return ((ItemAttribute)attribs[0]).Name; 46 else return null;51 else return type.GetPrettyName(); 47 52 } 48 53 public static string GetDescription(Type type) { 49 object[] attribs = type.GetCustomAttributes(typeof(ItemAttribute), true);54 object[] attribs = type.GetCustomAttributes(typeof(ItemAttribute), false); 50 55 if (attribs.Length > 0) return ((ItemAttribute)attribs[0]).Description; 51 else return null;56 else return string.Empty; 52 57 } 53 58 }
Note: See TracChangeset
for help on using the changeset viewer.