#region --------------- Copyright Dresser Wayne Pignone ------------- /* * $Log: /Wrk/WayneLibraries/Wrk/StateEngine/Description/EventDescriptionAttribute.cs $ * * 2 08-02-26 14:13 Mattias.larsson * Not "sealed" anymore. */ #endregion using System; namespace Wayne.Lib.StateEngine { /// /// Describe the event / transition relationship for a state class. /// [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] public class EventDescriptionAttribute : EnterDescriptionAttribute { #region Fields object eventType; #endregion #region Construction /// /// Describe an unconditional event / transition relationship for a state class. /// /// Event type object /// Transition that is performed. public EventDescriptionAttribute(object eventType, object transitionType) : this(eventType, "", transitionType) { this.eventType = eventType; } /// /// Describe the event / transition relationship for a state class. /// /// Event type object /// A descriptive text for the condition. /// Transition that is performed. public EventDescriptionAttribute(object eventType, string conditionText, object transitionType) : base(conditionText, transitionType) { this.eventType = eventType; } #endregion #region Properties /// /// Event type object. /// public object EventType { get { return eventType; } } #endregion #region IComparable Members /// /// Compares this attribute with another one. /// /// /// public override int CompareTo(object obj) { int result = 0; EventDescriptionAttribute compareEventDescriptionAttribute = obj as EventDescriptionAttribute; if (compareEventDescriptionAttribute != null) { if ((EventType != null) && (compareEventDescriptionAttribute.EventType != null)) { //result = EventType.GetType().FullName.CompareTo(compareEventDescriptionAttribute.EventType.GetType().FullName); //if (result == 0) { result = EventType.ToString().CompareTo(compareEventDescriptionAttribute.EventType.ToString()); if (result == 0) result = base.CompareTo(obj); } } else if (EventType != null) result = 1; else if (compareEventDescriptionAttribute.EventType != null) result = -1; } else { EnterDescriptionAttribute compareEnterDescriptionAttribute = obj as EnterDescriptionAttribute; if (compareEnterDescriptionAttribute != null) { // An EnterDescriptionAttribute should come before an EventDescriptionAttribute. return 1; } } return result; } #endregion } }