示例#1
0
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="cconditionValue">改变的数值</param>
 /// <param name="compareValue">比较的默认值</param>
 /// <param name="compareType">比较方式</param>
 protected Condition(ConditionValue <T> cconditionValue, object compareValue, CompareType compareType)
 {
     this._conditionValue = cconditionValue;
     this._compareValue   = (T)compareValue;
     _compareType         = SetConditionType(compareType);
     if (_compareType == CompareType.None)
     {
         throw new Exception(string.Format("{0} could not use {1}", type, compareType));
     }
 }
示例#2
0
        /// <summary>
        /// 创建过度条件
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="value"></param>
        /// <param name="CompareValue"></param>
        /// <param name="CompareType"></param>
        /// <returns></returns>
        public Condition <T> CreateCondition <T>(ConditionValue <T> value, T CompareValue, CompareType CompareType)
        {
            ICondition condtion;

            if (typeof(T) == typeof(bool))
            {
                condtion = new BoolCondition(value as ConditionValue <bool>, CompareValue, CompareType);
            }
            else if (typeof(T) == typeof(float))
            {
                condtion = new FloatCondition(value as ConditionValue <float>, CompareValue, CompareType);
            }
            else if (typeof(T) == typeof(int))
            {
                condtion = new IntCondition(value as ConditionValue <int>, CompareValue, CompareType);
            }
            else
            {
                throw new Exception("Fault Type Of T   " + typeof(T));
            }
            return(condtion as Condition <T>);
        }