示例#1
0
        /// <summary>
        /// 减值,如果成功输出计算后的数值
        /// </summary>
        /// <param name="number">ThresholdNumber对象</param>
        /// <param name="value">要减的差量数值。</param>
        /// <param name="newValue">输出减后的数值。</param>
        /// <returns>如果成功返回true,否则返回false。</returns>
        public static Boolean TrySubtract(this ThresholdNumber <Int16> number, Int16 value, out Int16 newValue)
        {
            Int16 oldValue;

            if (number.TryExchange(Convert.ToInt16(number.Value - value), out oldValue) == false)
            {
                newValue = oldValue;
                return(false);
            }
            else
            {
                newValue = Convert.ToInt16(oldValue - value);
                return(true);
            }
        }
示例#2
0
        /// <summary>
        /// 减值,如果成功输出计算后的数值
        /// </summary>
        /// <param name="number">ThresholdNumber对象</param>
        /// <param name="value">要减的差量数值。</param>
        /// <param name="newValue">输出减后的数值。</param>
        /// <returns>如果成功返回true,否则返回false。</returns>
        public static Boolean TrySubtract(this ThresholdNumber <Int32> number, Int32 value, out Int32 newValue)
        {
            Int32 oldValue;

            if (number.TryExchange(number.Value - value, out oldValue) == false)
            {
                newValue = oldValue;
                return(false);
            }
            else
            {
                newValue = oldValue - value;
                return(true);
            }
        }
示例#3
0
        /// <summary>
        ///  尝试减量数值,如果成功输出减量后的数值
        /// </summary>
        /// <param name="number">ThresholdNumber对象</param>
        /// <param name="value">输出减量后的数值</param>
        /// <returns>返回成功则返回true,否则返回false。</returns>
        public static Boolean TryDecrement(this ThresholdNumber <UInt32> number, out UInt32 value)
        {
            UInt32 oldValue;

            if (number.TryExchange(number.Value - 1, out oldValue) == false)
            {
                value = oldValue;
                return(false);
            }
            else
            {
                value = oldValue - 1;
                return(true);
            }
        }
 public static void Test()
 {
     try
     {
         ThresholdNumber <Int32> number = new ThresholdNumber <Int32>(10, 0, 0);
         number.Increment();
         number.Decrement();
         number.Add(10);
         number.Subtract(-1);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
示例#5
0
        /// <summary>
        ///  尝试减量数值,如果成功输出减量后的数值
        /// </summary>
        /// <param name="number">ThresholdNumber对象</param>
        /// <param name="value">输出减量后的数值</param>
        /// <returns>返回成功则返回true,否则返回false。</returns>
        public static Boolean TryDecrement(this ThresholdNumber <UInt16> number, out UInt16 value)
        {
            UInt16 oldValue;

            if (number.TryExchange(Convert.ToUInt16(number.Value - 1), out oldValue) == false)
            {
                value = oldValue;
                return(false);
            }
            else
            {
                value = Convert.ToUInt16(oldValue - 1);
                return(true);
            }
        }
示例#6
0
        /// <summary>
        /// 加值,如果成功输出计算后的数值
        /// </summary>
        /// <param name="number">ThresholdNumber对象</param>
        /// <param name="value">要增加的差量数值。</param>
        /// <param name="newValue">输出增加后的数值。</param>
        /// <returns>如果成功返回true,否则返回false。</returns>
        public static Boolean TryAdd(this ThresholdNumber <Byte> number, Byte value, out Byte newValue)
        {
            Byte oldValue;

            if (number.TryExchange(Convert.ToByte(number.Value + value), out oldValue) == false)
            {
                newValue = oldValue;
                return(false);
            }
            else
            {
                newValue = Convert.ToByte(oldValue + value);
                return(true);
            }
        }
示例#7
0
        /// <summary>
        /// 减值,如果成功输出计算后的数值
        /// </summary>
        /// <param name="number">ThresholdNumber对象</param>
        /// <param name="value">要减的差量数值。</param>
        /// <param name="newValue">输出减后的数值。</param>
        /// <returns>如果成功返回true,否则返回false。</returns>
        public static Boolean TrySubtract(this ThresholdNumber <Single> number, Single value, out Single newValue)
        {
            Single oldValue;

            if (number.TryExchange(number.Value - value, out oldValue) == false)
            {
                newValue = oldValue;
                return(false);
            }
            else
            {
                newValue = oldValue - value;
                return(true);
            }
        }
示例#8
0
        /// <summary>
        ///  尝试减量数值,如果成功输出减量后的数值
        /// </summary>
        /// <param name="number">ThresholdNumber对象</param>
        /// <param name="value">输出减量后的数值</param>
        /// <returns>返回成功则返回true,否则返回false。</returns>
        public static Boolean TryDecrement(this ThresholdNumber <Byte> number, out Byte value)
        {
            Byte oldValue;

            if (number.TryExchange(Convert.ToByte(number.Value - 1), out oldValue) == false)
            {
                value = oldValue;
                return(false);
            }
            else
            {
                value = Convert.ToByte(oldValue - 1);
                return(true);
            }
        }
示例#9
0
        /// <summary>
        /// 加值,如果成功输出计算后的数值
        /// </summary>
        /// <param name="number">ThresholdNumber对象</param>
        /// <param name="value">要增加的差量数值。</param>
        /// <param name="newValue">输出增加后的数值。</param>
        /// <returns>如果成功返回true,否则返回false。</returns>
        public static Boolean TryAdd(this ThresholdNumber <UInt32> number, UInt32 value, out UInt32 newValue)
        {
            UInt32 oldValue;

            if (number.TryExchange(number.Value + value, out oldValue) == false)
            {
                newValue = oldValue;
                return(false);
            }
            else
            {
                newValue = oldValue + value;
                return(true);
            }
        }
示例#10
0
        /// <summary>
        ///  尝试减量数值,如果成功输出减量后的数值
        /// </summary>
        /// <param name="number">ThresholdNumber对象</param>
        /// <param name="value">输出减量后的数值</param>
        /// <returns>返回成功则返回true,否则返回false。</returns>
        public static Boolean TryDecrement(this ThresholdNumber <Single> number, out Single value)
        {
            Single oldValue;

            if (number.TryExchange(number.Value - 1, out oldValue) == false)
            {
                value = oldValue;
                return(false);
            }
            else
            {
                value = oldValue - 1;
                return(true);
            }
        }
示例#11
0
        /// <summary>
        /// 加值,如果成功输出计算后的数值
        /// </summary>
        /// <param name="number">ThresholdNumber对象</param>
        /// <param name="value">要增加的差量数值。</param>
        /// <param name="newValue">输出增加后的数值。</param>
        /// <returns>如果成功返回true,否则返回false。</returns>
        public static Boolean TryAdd(this ThresholdNumber <UInt16> number, UInt16 value, out UInt16 newValue)
        {
            UInt16 oldValue;

            if (number.TryExchange(Convert.ToUInt16(number.Value + value), out oldValue) == false)
            {
                newValue = oldValue;
                return(false);
            }
            else
            {
                newValue = Convert.ToUInt16(oldValue + value);
                return(true);
            }
        }
示例#12
0
        /// <summary>
        /// 加值,如果成功输出计算后的数值
        /// </summary>
        /// <param name="number">ThresholdNumber对象</param>
        /// <param name="value">要增加的差量数值。</param>
        /// <param name="newValue">输出增加后的数值。</param>
        /// <returns>如果成功返回true,否则返回false。</returns>
        public static Boolean TryAdd(this ThresholdNumber <Int64> number, Int64 value, out Int64 newValue)
        {
            Int64 oldValue;

            if (number.TryExchange(number.Value + value, out oldValue) == false)
            {
                newValue = oldValue;
                return(false);
            }
            else
            {
                newValue = oldValue + value;
                return(true);
            }
        }
示例#13
0
        /// <summary>
        ///  尝试增量数值,如果成功输出增量后的数值
        /// </summary>
        /// <param name="number">ThresholdNumber对象</param>
        /// <param name="value">输出增量后的数值</param>
        /// <returns>返回成功则返回true,否则返回false。</returns>
        public static Boolean TryIncrement(this ThresholdNumber <Double> number, out Double value)
        {
            Double oldValue;

            if (number.TryExchange(number.Value + 1, out oldValue) == false)
            {
                value = oldValue;
                return(false);
            }
            else
            {
                value = oldValue + 1;
                return(true);
            }
        }
示例#14
0
        /// <summary>
        /// 减值,如果成功输出计算后的数值
        /// </summary>
        /// <param name="number">ThresholdNumber对象</param>
        /// <param name="value">要减的差量数值。</param>
        /// <param name="newValue">输出减后的数值。</param>
        /// <returns>如果成功返回true,否则返回false。</returns>
        public static Boolean TrySubtract(this ThresholdNumber <UInt64> number, UInt64 value, out UInt64 newValue)
        {
            UInt64 oldValue;

            if (number.TryExchange(number.Value - value, out oldValue) == false)
            {
                newValue = oldValue;
                return(false);
            }
            else
            {
                newValue = oldValue - value;
                return(true);
            }
        }
示例#15
0
        /// <summary>
        /// 加值,如果成功输出计算后的数值
        /// </summary>
        /// <param name="number">ThresholdNumber对象</param>
        /// <param name="value">要增加的差量数值。</param>
        /// <param name="newValue">输出增加后的数值。</param>
        /// <returns>如果成功返回true,否则返回false。</returns>
        public static Boolean TryAdd(this ThresholdNumber <Double> number, Double value, out Double newValue)
        {
            Double oldValue;

            if (number.TryExchange(number.Value + value, out oldValue) == false)
            {
                newValue = oldValue;
                return(false);
            }
            else
            {
                newValue = oldValue + value;
                return(true);
            }
        }
示例#16
0
 /// <summary>
 ///  增量数值,如果成功返回增量后的数值
 /// </summary>
 /// <param name="number">ThresholdNumber对象</param>
 /// <returns>返回增量后的数值</returns>
 /// <exception cref="System.ArgumentOutOfRangeException">ThresholdNumber is out of range.</exception>
 public static Int16 Increment(this ThresholdNumber <Int16> number)
 {
     return(Convert.ToInt16(number.Exchange(Convert.ToInt16(number.Value + 1)) + 1));
 }
示例#17
0
 /// <summary>
 /// 加值,如果成功返回计算后的数值
 /// </summary>
 /// <param name="number">ThresholdNumber对象</param>
 /// <param name="value">要增加的差量数值。</param>
 /// <returns>返回计算后的新数值。</returns>
 public static Single Add(this ThresholdNumber <Single> number, Single value)
 {
     return(number.Exchange(number.Value + value) + value);
 }
示例#18
0
 /// <summary>
 /// 加值,如果成功返回计算后的数值
 /// </summary>
 /// <param name="number">ThresholdNumber对象</param>
 /// <param name="value">要增加的差量数值。</param>
 /// <returns>返回计算后的新数值。</returns>
 public static Byte Add(this ThresholdNumber <Byte> number, Byte value)
 {
     return(Convert.ToByte(number.Exchange(Convert.ToByte(number.Value + value)) + value));
 }
示例#19
0
 /// <summary>
 /// 加值,如果成功返回计算后的数值
 /// </summary>
 /// <param name="number">ThresholdNumber对象</param>
 /// <param name="value">要增加的差量数值。</param>
 /// <returns>返回计算后的新数值。</returns>
 public static UInt16 Add(this ThresholdNumber <UInt16> number, UInt16 value)
 {
     return(Convert.ToUInt16(number.Exchange(Convert.ToUInt16(number.Value + value)) + value));
 }
示例#20
0
 /// <summary>
 /// 加值,如果成功返回计算后的数值
 /// </summary>
 /// <param name="number">ThresholdNumber对象</param>
 /// <param name="value">要增加的差量数值。</param>
 /// <returns>返回计算后的新数值。</returns>
 public static UInt32 Add(this ThresholdNumber <UInt32> number, UInt32 value)
 {
     return(number.Exchange(number.Value + value) + value);
 }
示例#21
0
 /// <summary>
 /// 加值,如果成功返回计算后的数值
 /// </summary>
 /// <param name="number">ThresholdNumber对象</param>
 /// <param name="value">要增加的差量数值。</param>
 /// <returns>返回计算后的新数值。</returns>
 public static Int64 Add(this ThresholdNumber <Int64> number, Int64 value)
 {
     return(number.Exchange(number.Value + value) + value);
 }
示例#22
0
 /// <summary>
 /// 减量数值,如果成功返回减量后的数值
 /// </summary>
 /// <param name="number">ThresholdNumber对象</param>
 /// <returns>返回减量后的数值</returns>
 /// <exception cref="System.ArgumentOutOfRangeException">ThresholdNumber is out of range.</exception>
 public static Single Decrement(this ThresholdNumber <Single> number)
 {
     return(number.Exchange(number.Value - 1) - 1);
 }
示例#23
0
 /// <summary>
 ///  减量数值,如果成功返回减量后的数值
 /// </summary>
 /// <param name="number">ThresholdNumber对象</param>
 /// <returns>返回减量后的数值</returns>
 /// <exception cref="System.ArgumentOutOfRangeException">ThresholdNumber is out of range.</exception>
 public static Byte Decrement(this ThresholdNumber <Byte> number)
 {
     return(Convert.ToByte(number.Exchange(Convert.ToByte(number.Value - 1)) - 1));
 }
示例#24
0
 /// <summary>
 ///  减量数值,如果成功返回减量后的数值
 /// </summary>
 /// <param name="number">ThresholdNumber对象</param>
 /// <returns>返回减量后的数值</returns>
 /// <exception cref="System.ArgumentOutOfRangeException">ThresholdNumber is out of range.</exception>
 public static UInt16 Decrement(this ThresholdNumber <UInt16> number)
 {
     return(Convert.ToUInt16(number.Exchange(Convert.ToUInt16(number.Value - 1)) - 1));
 }
示例#25
0
 /// <summary>
 ///  减量数值,如果成功返回减量后的数值
 /// </summary>
 /// <param name="number">ThresholdNumber对象</param>
 /// <returns>返回减量后的数值</returns>
 /// <exception cref="System.ArgumentOutOfRangeException">ThresholdNumber is out of range.</exception>
 public static UInt32 Decrement(this ThresholdNumber <UInt32> number)
 {
     return(number.Exchange(number.Value - 1) - 1);
 }
示例#26
0
 /// <summary>
 ///  减量数值,如果成功返回减量后的数值
 /// </summary>
 /// <param name="number">ThresholdNumber对象</param>
 /// <returns>返回减量后的数值</returns>
 /// <exception cref="System.ArgumentOutOfRangeException">ThresholdNumber is out of range.</exception>
 public static Int64 Decrement(this ThresholdNumber <Int64> number)
 {
     return(number.Exchange(number.Value - 1) - 1);
 }
示例#27
0
 /// <summary>
 ///  增量数值,如果成功返回增量后的数值
 /// </summary>
 /// <param name="number">ThresholdNumber对象</param>
 /// <returns>返回增量后的数值</returns>
 /// <exception cref="System.ArgumentOutOfRangeException">ThresholdNumber is out of range.</exception>
 public static Int32 Increment(this ThresholdNumber <Int32> number)
 {
     return(number.Exchange(number.Value + 1) + 1);
 }
示例#28
0
 /// <summary>
 /// 增量数值,如果成功返回增量后的数值
 /// </summary>
 /// <param name="number">ThresholdNumber对象</param>
 /// <returns>返回增量后的数值</returns>
 /// <exception cref="System.ArgumentOutOfRangeException">ThresholdNumber is out of range.</exception>
 public static Double Increment(this ThresholdNumber <Double> number)
 {
     return(number.Exchange(number.Value + 1) + 1);
 }
示例#29
0
 /// <summary>
 /// 减值,如果成功返回计算后的数值
 /// </summary>
 /// <param name="number">ThresholdNumber对象</param>
 /// <param name="value">要减的差量数值。</param>
 /// <returns>返回计算后的新数值。</returns>
 public static Single Subtract(this ThresholdNumber <Single> number, Single value)
 {
     return(number.Exchange(number.Value - value) - value);
 }
示例#30
0
 /// <summary>
 ///  增量数值,如果成功返回增量后的数值
 /// </summary>
 /// <param name="number">ThresholdNumber对象</param>
 /// <returns>返回增量后的数值</returns>
 /// <exception cref="System.ArgumentOutOfRangeException">ThresholdNumber is out of range.</exception>
 public static UInt64 Increment(this ThresholdNumber <UInt64> number)
 {
     return(number.Exchange(number.Value + 1) + 1);
 }