Esempio n. 1
0
        object GetEvalResult(WarewolfDataEvaluationCommon.WarewolfEvalResult evalResult, int i)
        {
            if (evalResult.IsWarewolfAtomListresult)
            {
                WarewolfAtomList <DataASTMutable.WarewolfAtom> lst = ((WarewolfDataEvaluationCommon.WarewolfEvalResult.WarewolfAtomListresult)evalResult).Item;
                if (i > lst.Count)
                {
                    return(null);
                }
                return(WarewolfDataEvaluationCommon.AtomToJsonCompatibleObject(lst[i]));
            }
            if (evalResult.IsWarewolfAtomResult)
            {
                if (i == 0)
                {
                    return(WarewolfDataEvaluationCommon.EvalResultToJsonCompatibleObject(evalResult));
                }
                return(null);
            }
            if (evalResult.IsWarewolfRecordSetResult)
            {
                DataASTMutable.WarewolfRecordset recset = ((WarewolfDataEvaluationCommon.WarewolfEvalResult.WarewolfRecordSetResult)EvalResult).Item;

                KeyValuePair <string, WarewolfAtomList <DataASTMutable.WarewolfAtom> >[] data = recset.Data.ToArray();
                var jObjects = new List <JObject>();
                for (int j = 0; j < recset.Count; j++)
                {
                    var a = new JObject();
                    foreach (KeyValuePair <string, WarewolfAtomList <DataASTMutable.WarewolfAtom> > pair in data)
                    {
                        if (pair.Key != WarewolfDataEvaluationCommon.PositionColumn)
                        {
                            try
                            {
                                a.Add(new JProperty(pair.Key, WarewolfDataEvaluationCommon.AtomToJsonCompatibleObject(pair.Value[j])));
                            }
                            catch (Exception)
                            {
                                a.Add(new JProperty(pair.Key, null));
                            }
                        }
                    }
                    jObjects.Add(a);
                }
                return(jObjects);
            }
            throw new Exception("Invalid result type was encountered from warewolfstorage");
        }