Ejemplo n.º 1
0
 public void AddParameter(CustomParameter parameter)
 {
     paramDict.Add(parameter.name, parameter);
 }
        static bool MatchesParameter(CustomParameter parameter, CompareMode compareMode, string valueStrig, out object paramVal)
        {
            switch (parameter.paramType)
            {
            case CustomParameter.ParamType.IntValue:
            {
                int checkVal = int.Parse(valueStrig);
                int intValue = parameter.GetValue <int>();
                paramVal = intValue;

                switch (compareMode)
                {
                case CompareMode.Equals: return(intValue == checkVal);

                case CompareMode.NotEquals: return(intValue != checkVal);

                case CompareMode.MoreThan: return(intValue > checkVal);

                case CompareMode.MoreThanOrEqual: return(intValue >= checkVal);

                case CompareMode.LessThan: return(intValue < checkVal);

                case CompareMode.LessThenOrEqual: return(intValue <= checkVal);
                }
                return(false);
            }

            case CustomParameter.ParamType.FloatValue:
            {
                float checkVal   = float.Parse(valueStrig);
                float floatValue = parameter.GetValue <float>();
                paramVal = floatValue;

                switch (compareMode)
                {
                case CompareMode.Equals: return(floatValue == checkVal);

                case CompareMode.NotEquals: return(floatValue != checkVal);

                case CompareMode.MoreThan: return(floatValue > checkVal);

                case CompareMode.MoreThanOrEqual: return(floatValue >= checkVal);

                case CompareMode.LessThan: return(floatValue < checkVal);

                case CompareMode.LessThenOrEqual: return(floatValue <= checkVal);
                }
                return(false);
            }

            case CustomParameter.ParamType.BoolValue:
            {
                bool boolValue = parameter.GetValue <bool>();
                paramVal = boolValue;
                if (parameter.name == valueStrig)
                {
                    return(boolValue);
                }

                bool checkVal = bool.Parse(valueStrig);
                switch (compareMode)
                {
                case CompareMode.Equals: return(boolValue == checkVal);

                case CompareMode.NotEquals: return(boolValue != checkVal);
                }

                return(false);
            }

            case CustomParameter.ParamType.StringValue: {
                string stringVal = parameter.GetValue <string>();
                paramVal = stringVal;
                switch (compareMode)
                {
                case CompareMode.Equals: return(stringVal == valueStrig);

                case CompareMode.NotEquals: return(stringVal != valueStrig);
                }
                return(false);
            }
            }
            paramVal = null;
            return(true);
        }