/// <summary> /// Override of Equals() method to compare enum value of both objects /// </summary> /// <param name="obj">Object to compare</param> /// <returns>True if the objects have the same running level enum value, False if not</returns> public override bool Equals(object obj) { if (obj == null) { return(false); } if (GetType() != obj.GetType()) { return(false); } RunningLevel otherRunningLevel = (RunningLevel)obj; return(BaseRunningLevel == otherRunningLevel.BaseRunningLevel); }
/// <summary> /// Know if the current running level has another one to child level /// </summary> /// <param name="otherRunningLevel">Another running level</param> /// <returns>True if the other running is a child level of the current one, False if not</returns> public bool HasChild(RunningLevel otherRunningLevel) { return(Children.Contains(otherRunningLevel.BaseRunningLevel) || Children.Any(l => Values[l].HasChild(otherRunningLevel))); }
/// <summary> /// Know if the receiver will be called specific running level nor one of next level /// </summary> /// <param name="runningLevel">Running level</param> /// <returns>True if the receiver will be called, False if not</returns> public bool IsReceiverCalledOrDeeper(RunningLevel runningLevel) => runningLevels.Any(l => l <= runningLevel);
/// <summary> /// Know if the current running level has another one as parent level /// </summary> /// <param name="otherRunningLevel">Another running level</param> /// <returns>True if the other running level is a parent level of the current one, False if not</returns> public bool HasParent(RunningLevel otherRunningLevel) { return(Parent.HasValue && (Parent.Value == otherRunningLevel.BaseRunningLevel || Values[Parent.Value].HasParent(otherRunningLevel))); }
/// <summary> /// Know if the receiver should be called at a specific running level /// </summary> /// <param name="runningLevel">Running level</param> /// <returns>True if the receiver should be called, False if not</returns> public bool IsReceiverCalled(RunningLevel runningLevel) => runningLevels.Contains(runningLevel);