Removing now redundant specific HID EAR events.
2 using System.Collections.Generic;
5 using System.Threading.Tasks;
9 using System.Collections.Generic;
10 using System.Runtime.Serialization;
11 using System.ComponentModel;
13 namespace SharpLib.Ear
17 /// EAR object provides serialization support.
18 /// It assumes most derived class is decorated with AttributeObject.
21 [KnownType("DerivedTypes")]
22 public abstract class Object: IComparable, INotifyPropertyChanged
24 private bool iConstructed = false;
32 /// Needed as our constructor is not called following internalization.
34 public void Construct()
46 protected virtual void DoConstruct()
58 State iCurrentState = State.Rest;
59 public State CurrentState { get { return iCurrentState; } set { OnStateLeave(); iCurrentState = value; OnStateEnter(); } }
64 protected virtual void OnStateLeave()
72 protected virtual void OnStateEnter()
78 /// Static object name.
82 //Get the name of this object attribute
83 get { return Utils.Reflection.GetAttribute<AttributeObject>(GetType()).Name; }
88 /// Static object description.
90 public string Description
92 //Get the description of this object attribute
93 get { return Utils.Reflection.GetAttribute<AttributeObject>(GetType()).Description; }
98 /// Dynamic object description.
100 /// <returns></returns>
101 public virtual string Brief()
107 /// Needed to make sure our sorting makes sense
109 /// <param name="obj"></param>
110 /// <returns></returns>
111 public int CompareTo(object obj)
113 //Sort by object name
114 return Utils.Reflection.GetAttribute<AttributeObject>(GetType()).Name.CompareTo(obj.GetType());
118 /// Tells whether the current object configuration is valid.
120 /// <returns></returns>
121 public virtual bool IsValid()
127 /// So that data contract knows all our types.
129 /// <returns></returns>
130 private static IEnumerable<Type> DerivedTypes()
132 return SharpLib.Utils.Reflection.GetDerivedTypes<Object>();
138 public event PropertyChangedEventHandler PropertyChanged;
142 /// Invoke our event.
144 /// <param name="name"></param>
145 protected void OnPropertyChanged(string name)
147 PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));