123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- #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
- {
- /// <summary>
- /// Describe the event / transition relationship for a state class.
- /// </summary>
- [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
- public class EventDescriptionAttribute : EnterDescriptionAttribute
- {
- #region Fields
- object eventType;
- #endregion
- #region Construction
- /// <summary>
- /// Describe an unconditional event / transition relationship for a state class.
- /// </summary>
- /// <param name="eventType">Event type object</param>
- /// <param name="transitionType">Transition that is performed.</param>
- public EventDescriptionAttribute(object eventType, object transitionType)
- : this(eventType, "", transitionType)
- {
- this.eventType = eventType;
- }
- /// <summary>
- /// Describe the event / transition relationship for a state class.
- /// </summary>
- /// <param name="eventType">Event type object</param>
- /// <param name="conditionText">A descriptive text for the condition.</param>
- /// <param name="transitionType">Transition that is performed.</param>
- public EventDescriptionAttribute(object eventType, string conditionText, object transitionType)
- : base(conditionText, transitionType)
- {
- this.eventType = eventType;
- }
- #endregion
- #region Properties
- /// <summary>
- /// Event type object.
- /// </summary>
- public object EventType
- {
- get { return eventType; }
- }
- #endregion
- #region IComparable Members
- /// <summary>
- /// Compares this attribute with another one.
- /// </summary>
- /// <param name="obj"></param>
- /// <returns></returns>
- 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
- }
- }
|