Published v1.0.1.0.
Updating Harmony library to v0.5.0
2 using System.Collections.Generic;
5 using System.Threading.Tasks;
6 using System.Runtime.Serialization;
7 using System.ComponentModel;
13 /// EAR object provides serialization support.
14 /// It assumes most derived class is decorated with AttributeObject.
17 [KnownType("DerivedTypes")]
18 public abstract class Object: IComparable, INotifyPropertyChanged
20 private bool iConstructed = false;
28 /// Needed as our constructor is not called following internalization.
30 public void Construct()
42 protected virtual void DoConstruct()
54 State iCurrentState = State.Rest;
55 public State CurrentState { get { return iCurrentState; } set { OnStateLeave(); iCurrentState = value; OnStateEnter(); } }
60 protected virtual void OnStateLeave()
68 protected virtual void OnStateEnter()
74 /// Static object name.
78 //Get the name of this object attribute
79 get { return Utils.Reflection.GetAttribute<AttributeObject>(GetType()).Name; }
84 /// Static object description.
86 public string Description
88 //Get the description of this object attribute
89 get { return Utils.Reflection.GetAttribute<AttributeObject>(GetType()).Description; }
94 /// Dynamic object description.
96 /// <returns></returns>
97 public virtual string Brief()
103 /// Needed to make sure our sorting makes sense
105 /// <param name="obj"></param>
106 /// <returns></returns>
107 public int CompareTo(object obj)
109 //Sort by object name
110 return Utils.Reflection.GetAttribute<AttributeObject>(GetType()).Name.CompareTo(obj.GetType());
114 /// Tells whether the current object configuration is valid.
116 /// <returns></returns>
117 public virtual bool IsValid()
123 /// So that data contract knows all our types.
125 /// <returns></returns>
126 private static IEnumerable<Type> DerivedTypes()
128 return SharpLib.Utils.Reflection.GetDerivedTypes<Object>();
134 public event PropertyChangedEventHandler PropertyChanged;
138 /// Invoke our event.
140 /// <param name="name"></param>
141 protected void OnPropertyChanged(string name)
143 PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));