Пример #1
0
        /// <summary>
        /// 将后者的属性增加到前者上
        /// </summary>
        /// <param name="t">T</param>
        /// <param name="t1">T1.</param>
        /// <param name="type">数值增加类型:百分比增加还是按值增加</param>
        /// <param name="isGood">增加还是减少,True为增加,反之为减少.默认为增加</param>
        public static T UpdateProperty <T, T1>(T t, T1 t1, NumericalType type, bool isGood = true)
            where T : BaseProperty
            where T1 : BaseProperty
        {
            switch (type)
            {
            case NumericalType.数值:
                return(UpdatePropertyValue(t, t1, isGood));

            case NumericalType.百分比:
                return(UpdatePropertyPercent(t, t1, isGood));

            default:
                throw new Exception();
            }
        }
Пример #2
0
 internal static Type GetTypeObject(this NumericalType numericalType)
 {
     return(numericalType switch
     {
         NumericalType.SignedByte => typeof(sbyte),
         NumericalType.UnsignedByte => typeof(byte),
         NumericalType.SignedShort => typeof(short),
         NumericalType.UnsignedShort => typeof(ushort),
         NumericalType.SignedInt => typeof(int),
         NumericalType.UnsignedInt => typeof(uint),
         NumericalType.SignedLong => typeof(long),
         NumericalType.UnsignedLong => typeof(ulong),
         NumericalType.SinglePrecision => typeof(float),
         NumericalType.DoublePrecision => typeof(double),
         NumericalType.DecimalNumber => typeof(decimal),
         _ => throw new ArgumentOutOfRangeException(nameof(numericalType))
     });
Пример #3
0
        public ArithmeticNumeric(object value) {
            p_Value = value;

            //get what type the value is
            if (value is sbyte) { p_Type = NumericalType.SBYTE; }
            else if (value is byte) { p_Type = NumericalType.BYTE; }
            else if (value is short) { p_Type = NumericalType.INT16; }
            else if (value is ushort) { p_Type = NumericalType.UINT16; }
            else if (value is int) { p_Type = NumericalType.INT32; }
            else if (value is uint) { p_Type = NumericalType.UINT32; }
            else if (value is long) { p_Type = NumericalType.INT64; }
            else if (value is ulong) { p_Type = NumericalType.UINT64; }
            else if (value is float) { p_Type = NumericalType.FLOAT; }
            else if (value is double) { p_Type = NumericalType.DOUBLE; }
            else { 
                //it's invalid
                throw new Exception("Invalid numerical object");
            }
        }