Esempio n. 1
0
        // take conditions and JSON, decode it, execute..
        private bool?CheckCondition(List <Condition> fel,
                                    Object cls,                   // object with data in it
                                    ConditionVariables othervars, // any other variables to present to the condition, in addition to the JSON variables
                                    out string errlist,           // null if okay..
                                    List <Condition> passed)      // null or conditions passed
        {
            errlist = null;

            ConditionVariables valuesneeded = new ConditionVariables();

            foreach (Condition fe in fel)        // find all values needed
            {
                fe.IndicateValuesNeeded(ref valuesneeded);
            }

            try
            {
                valuesneeded.GetValuesIndicated(cls);
                valuesneeded.Add(othervars);
                return(CheckConditions(fel, valuesneeded, out errlist, passed));    // and check, passing in the values collected against the conditions to test.
            }
            catch (Exception)
            {
                errlist = "JSON failed to parse!";
                return(null);
            }
        }