Ejemplo n.º 1
0
        internal string ToJson()
        {
            var di = new DataItem();

            if (String.IsNullOrEmpty(Message))
            {
                Message = "The request is invalid";
            }
            di.Set("Message", Message);
            var ms  = new DataItem();
            var add = false;

            foreach (var item in _errors)
            {
                ms.Set(item.Key, item.Value.ToArray());
                add = true;
            }
            if (add)
            {
                di.Set("ModelState", ms);
            }



            return(di.ToJson());
        }
Ejemplo n.º 2
0
        internal DataItem CountRows(WebRequest req)
        {
            long start, numOfRows;

            setupBp(req, out start, out numOfRows);
            try
            {
                var result = new DataItem();
                var envE   = this.From as ENV.Data.Entity;
                result.Set("count", envE.CountRows(_bp.Where));
                return(result);
            }
            finally
            {
                _bp.OrderBy = _origOrderBy;
                _tempFilter.Clear();
            }
        }
Ejemplo n.º 3
0
            public void Process(char c, SetCharProcessor setState)
            {
                switch (c)
                {
                case '}':
                    _done(di);
                    setState(_nextProcessor, false);
                    break;

                case ',':
                    break;

                case ' ':
                case '\t':
                case '\r':
                case '\n':
                    break;

                default:
                    var vr = new valueReader((n, v) => di.Set(n, v), this);
                    setState(new ReadValueThatMayOrMayNotBeQuoted(vr, ':', vr.setName), c != ',');
                    break;
                }
            }
Ejemplo n.º 4
0
        public static DataItem FromJson(string s)
        {
            if (string.IsNullOrEmpty(s))
            {
                throw new InvalidOperationException("Empty JSON Content - did you forget settings the ContentType:application/json");
            }
            var di = new DataItem();

            foreach (var pair in JObject.Parse(s))
            {
                object value = pair.Value.ToObject <object>();
                if (value is JArray)
                {
                    value = DataList.FromJson(value.ToString());
                }
                else
                {
                    value = value.ToString();
                }
                di.Set(pair.Key, value);
            }

            return(di);
        }
Ejemplo n.º 5
0
 internal void SaveTo(DataItem x)
 {
     x.Set(_key, _getValueFromRow());
 }