public void CanExtremityTypeSetBeginEnd() { Assert.IsNull(((ExtremityType?)null).SetBegin(true)); Assert.IsNull(((ExtremityType?)null).SetEnd(true)); Assert.IsNull(((ExtremityType?)null).SetBegin(false)); Assert.IsNull(((ExtremityType?)null).SetEnd(false)); ExtremityType value = ExtremityType.Both; Assert.AreEqual(ExtremityType.JustEnd, value = value.SetBegin(false)); Assert.AreEqual(ExtremityType.JustEnd, value = value.SetEnd(true)); Assert.AreEqual(ExtremityType.Both, value = value.SetBegin(true)); Assert.AreEqual(ExtremityType.JustBegin, value = value.SetEnd(false)); Assert.AreEqual(ExtremityType.None, value.SetBegin(false)); }
/// <summary> /// Recompute the extremity type from its current <paramref name="value"/> /// and the given environmental flags: <paramref name="matchFrom"/> and /// <paramref name="matchTo"/> control the Begin and End portion of the /// extremity type, but only take effect if the corresponding /// <paramref name="processFrom"/> or <paramref name="processTo"/> flag /// is set. /// </summary> /// <returns>The computed new extremity type.</returns> public static ExtremityType Recompute(this ExtremityType value, bool processFrom, bool processTo, bool matchFrom, bool matchTo) { if (processFrom) { value = value.SetBegin(matchFrom); } if (processTo) { value = value.SetEnd(matchTo); } return(value); }
public static ExtremityType?SetBegin(this ExtremityType?value, bool flag) { return(value?.SetBegin(flag)); }