示例#1
0
        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));
        }
示例#2
0
        /// <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);
        }
示例#3
0
 public static ExtremityType?SetEnd(this ExtremityType?value, bool flag)
 {
     return(value?.SetEnd(flag));
 }