Changeset 2653 for trunk/sources/HeuristicLab.Core/3.3/ItemBase.cs
- Timestamp:
- 01/20/10 05:00:28 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core/3.3/ItemBase.cs
r2546 r2653 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.ComponentModel; 24 25 using System.Text; 25 26 using System.Xml; … … 33 34 /// Represents the base class for all basic item types. 34 35 /// </summary> 36 [EmptyStorableClass] 35 37 [Item("ItemBase", "Base class for all HeuristicLab items.")] 36 [EmptyStorableClass] 37 public abstract class ItemBase : IItem { 38 public virtual string Name { 39 get { 40 if (ItemAttribute.GetName(this.GetType()) != null) 41 return ItemAttribute.GetName(this.GetType()); 42 else 43 return this.GetType().Name; 44 } 38 public abstract class ItemBase : DeepCloneableBase, IItem { 39 public virtual string ItemName { 40 get { return ItemAttribute.GetName(this.GetType()); } 45 41 } 46 public virtual string Description { 47 get { 48 if (ItemAttribute.GetDescription(this.GetType()) != null) 49 return ItemAttribute.GetDescription(this.GetType()); 50 else 51 return "No description available."; 52 } 42 public virtual string ItemDescription { 43 get { return ItemAttribute.GetDescription(this.GetType()); } 53 44 } 54 public virtual Image Image { 55 get { return Resources.HeuristicLab; } 56 } 57 58 /// <summary> 59 /// Creates a deep clone of this instance. 60 /// </summary> 61 /// <remarks> 62 /// This method is the entry point for creating a deep clone of a whole object graph. 63 /// </remarks> 64 /// <returns>A clone of this instance.</returns> 65 public object Clone() { 66 return Clone(new Cloner()); 67 } 68 69 /// <summary> 70 /// Creates a deep clone of this instance. 71 /// </summary> 72 /// <remarks>This method should not be called directly. It is used for creating clones of 73 /// objects which are contained in the object that is currently cloned.</remarks> 74 /// <param name="cloner">The cloner which is responsible for keeping track of all already 75 /// cloned objects.</param> 76 /// <returns>A clone of this instance.</returns> 77 public virtual IItem Clone(ICloner cloner) { 78 ItemBase clone = (ItemBase)Activator.CreateInstance(this.GetType()); 79 cloner.RegisterClonedObject(this, clone); 80 return clone; 45 public virtual Image ItemImage { 46 get { return VS2008ImageLibrary.Class; } 81 47 } 82 48 … … 86 52 /// <returns>The type name of the current instance.</returns> 87 53 public override string ToString() { 88 return GetType().Name;54 return ItemName; 89 55 } 90 56 91 /// <summary> 92 /// Fires a new <c>Changed</c> event. 93 /// </summary> 94 /// <remarks>Calls <see cref="OnChanged"/>.</remarks> 95 public void FireChanged() { 96 OnChanged(); 57 public event ChangedEventHandler Changed; 58 protected void OnChanged() { 59 OnChanged(new ChangedEventArgs()); 97 60 } 98 99 /// <summary> 100 /// Occurs when the current item was changed. 101 /// </summary> 102 public event EventHandler Changed; 103 /// <summary> 104 /// Fires a new <c>Changed</c> event. 105 /// </summary> 106 protected virtual void OnChanged() { 107 if (Changed != null) 108 Changed(this, new EventArgs()); 61 protected virtual void OnChanged(ChangedEventArgs e) { 62 if ((e.RegisterChangedObject(this)) && (Changed != null)) 63 Changed(this, e); 109 64 } 110 65 }
Note: See TracChangeset
for help on using the changeset viewer.