Beispiel #1
0
        /// <summary>
        /// Converts the specified model to json.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        internal static string Convert(JsonModel model)
        {
            var converter = new LiteJsonWriter();

            using (var jsonWriter = new StringWriter())
            {
                converter._writer = new JsonTextWriter(jsonWriter)
                {
                    QuoteName = false,
                };
                if (RafyEnvironment.IsDebuggingEnabled)
                {
                    converter._writer.Formatting = Formatting.Indented;
                }

                //使用 JsonSerializer 会通过反射把对象的所有属性进行序列化,这时,不能对这个过程进行控制。
                //var serializer = new JsonSerializer();
                //serializer.Serialize(converter._writer, model);

                converter.WriteJsonModel(model);

                var json = jsonWriter.ToString();

                return(json);
            }
        }
Beispiel #2
0
 protected override void ToJson(LiteJsonWriter json)
 {
     json.WriteProperty("name", name);
     if (!persist) json.WriteProperty("persist", persist);
     json.WritePropertyIf("defaultValue", defaultValue);
     json.WriteProperty("type", ServerTypeHelper.GetClientFieldTypeName(type));
 }
Beispiel #3
0
        protected override void ToJson(LiteJsonWriter json)
        {
            json.WritePropertyIf("text", text);

            this.SetProperty("command", command);

            base.ToJson(json);
        }
Beispiel #4
0
        internal void ToJsonInternal(LiteJsonWriter json, JsonWriter writer)
        {
            writer.WriteStartObject();

            this.ToJson(json);

            writer.WriteEndObject();
        }
Beispiel #5
0
        internal void ToJsonInternal(LiteJsonWriter json, JsonWriter writer)
        {
            writer.WriteStartObject();

            this.ToJson(json);

            writer.WriteEndObject();
        }
Beispiel #6
0
        protected override void ToJson(LiteJsonWriter json)
        {
            //json.WriteProperty("autoDestroy", true);

            json.WritePropertyIf("fields", fields);
            json.WritePropertyIf("data", data);

            base.ToJson(json);
        }
Beispiel #7
0
        protected override void ToJson(LiteJsonWriter json)
        {
            json.WritePropertyIf("queryMode", queryMode);
            json.WritePropertyIf("displayField", displayField);
            json.WritePropertyIf("valueField", valueField);
            json.WritePropertyIf("store", store);

            base.ToJson(json);
        }
Beispiel #8
0
        protected override void ToJson(LiteJsonWriter json)
        {
            json.WriteProperty("type", "belongsTo");
            json.WritePropertyIf("foreignKey", foreignKey);
            json.WriteProperty("primaryKey", "Id");
            json.WritePropertyIf("associationKey", associationKey);

            base.ToJson(json);
        }
Beispiel #9
0
        protected override void ToJson(LiteJsonWriter json)
        {
            int i = 0, c = this._properties.Count;

            foreach (var kv in this._properties)
            {
                json.WriteProperty(kv.Key, kv.Value);
                i++;
            }
        }
Beispiel #10
0
        protected override void ToJson(LiteJsonWriter json)
        {
            int i = 0, c = this._properties.Count;

            foreach (var kv in this._properties)
            {
                json.WriteProperty(kv.Key, kv.Value);
                i++;
            }
        }
Beispiel #11
0
        protected override void ToJson(LiteJsonWriter json)
        {
            json.WritePropertyIf("name", name);
            json.WritePropertyIf("anchor", anchor);
            json.WritePropertyIf("fieldLabel", fieldLabel);
            json.WritePropertyIf("visibilityIndicator", visibilityIndicator);
            if (isReadonly) { json.WriteProperty("readOnly", isReadonly); }

            this.SetProperty("xtype", xtype);
            base.ToJson(json);
        }
Beispiel #12
0
        protected override void ToJson(LiteJsonWriter json)
        {
            if (children.Count > 0) { json.WriteProperty("entities", children); }
            else { json.WriteProperty("leaf", true); }

            //if (expanded) json.WriteProperty("expanded", expanded);

            if (!this.HasDynamicProperty) { this.SetProperty("e", "1"); }

            base.ToJson(json);
        }
Beispiel #13
0
        protected override void ToJson(LiteJsonWriter json)
        {
            json.WriteProperty("type", "hasMany");
            json.WritePropertyIf("name", name);
            json.WriteProperty("primaryKey", "Id");
            json.WritePropertyIf("foreignKey", foreignKey);

            if (autoLoad) { json.WriteProperty("autoLoad", true); }

            base.ToJson(json);
        }
Beispiel #14
0
        protected override void ToJson(LiteJsonWriter json)
        {
            //当使用自定义数据源时,强制其使用本地数据。
            if (!string.IsNullOrEmpty(this.dataSourceProperty))
            {
                this.queryMode = "local";
            }

            json.WritePropertyIf("model", model);
            json.WritePropertyIf("dataSourceProperty", dataSourceProperty);

            base.ToJson(json);
        }
Beispiel #15
0
        protected override void ToJson(LiteJsonWriter json)
        {
            json.WriteProperty("header", header);
            json.WritePropertyIf("xtype", xtype);
            json.WritePropertyIf("editor", editor);
            if (locked) { json.WritePropertyIf("locked", locked); }

            if (flex > 0)
            {
                json.WriteProperty("flex", flex);
            }
            json.WriteProperty("dataIndex", dataIndex);
        }
Beispiel #16
0
        protected override void ToJson(LiteJsonWriter json)
        {
            if (isTree)
            {
                json.WritePropertyIf("isTree", isTree);
            }

            json.WriteProperty("fields", fields);

            if (associations.Count > 0)
            {
                json.WriteProperty("associations", associations);
            }
        }
Beispiel #17
0
 /// <summary>
 /// Writes all properties by reflection.
 /// </summary>
 /// <param name="json">The json writer.</param>
 protected void WriteAllProperties(LiteJsonWriter json)
 {
     var properties = this.GetType().GetProperties();
     for (int i = 0, c = properties.Length; i < c; i++)
     {
         var property = properties[i];
         var value = property.GetValue(this, null);
         if (value is IEnumerable<JsonModel>)
         {
             json.WriteProperty(property.Name, value as IEnumerable<JsonModel>);
         }
         else
         {
             json.WriteProperty(property.Name, value);
         }
     }
 }
Beispiel #18
0
        /// <summary>
        /// Writes all properties by reflection.
        /// </summary>
        /// <param name="json">The json writer.</param>
        protected void WriteAllProperties(LiteJsonWriter json)
        {
            var properties = this.GetType().GetProperties();

            for (int i = 0, c = properties.Length; i < c; i++)
            {
                var property = properties[i];
                var value    = property.GetValue(this, null);
                if (value is IEnumerable <JsonModel> )
                {
                    json.WriteProperty(property.Name, value as IEnumerable <JsonModel>);
                }
                else
                {
                    json.WriteProperty(property.Name, value);
                }
            }
        }
Beispiel #19
0
 /// <summary>
 /// 子类重写此方法来实现 json 序列化的自定义。
 /// </summary>
 /// <param name="json"></param>
 protected abstract void ToJson(LiteJsonWriter json);
Beispiel #20
0
 protected override void ToJson(LiteJsonWriter json)
 {
     json.WriteProperty("model", ClientEntities.GetClientName(model));
     json.WriteProperty("total", total);
     json.WriteProperty("entities", entities);
 }
Beispiel #21
0
        protected override void ToJson(LiteJsonWriter json)
        {
            if (tbar.Count > 0) { json.WriteProperty("tbar", tbar); }

            json.WriteProperty("columns", columns);
        }
Beispiel #22
0
 protected override void ToJson(LiteJsonWriter json)
 {
     json.WritePropertyIf("model", model);
     json.WritePropertyIf("viewName", viewName);
     json.WritePropertyIf("label", label);
     json.WritePropertyIf("groupBy", groupBy);
     json.WritePropertyIf("gridConfig", gridConfig);
     json.WritePropertyIf("formConfig", formConfig);
     json.WritePropertyIf("storeConfig", storeConfig);
 }
Beispiel #23
0
 protected override void ToJson(LiteJsonWriter json)
 {
 }
Beispiel #24
0
 /// <summary>
 /// 返回当前对象对应的 json 字符串
 /// </summary>
 /// <returns></returns>
 public string ToJsonString()
 {
     return(LiteJsonWriter.Convert(this));
 }
 protected override void ToJson(LiteJsonWriter json)
 {
     json.WritePropertyIf("keyLabel", keyLabel);
     json.WritePropertyIf("url", url);
     json.WritePropertyIf("model", model);
     json.WritePropertyIf("viewName", viewName);
     json.WritePropertyIf("clientRuntime", clientRuntime);
     if (children.Count > 0) { json.WritePropertyIf("children", children); }
 }
Beispiel #26
0
 protected override void ToJson(LiteJsonWriter json)
 {
     json.WriteProperty("model", model);
 }
Beispiel #27
0
        /// <summary>
        /// Converts the specified model to json.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        internal static string Convert(JsonModel model)
        {
            var converter = new LiteJsonWriter();

            using (var jsonWriter = new StringWriter())
            {
                converter._writer = new JsonTextWriter(jsonWriter)
                {
                    QuoteName = false,
                };
                if (RafyEnvironment.IsDebuggingEnabled)
                {
                    converter._writer.Formatting = Formatting.Indented;
                }

                //使用 JsonSerializer 会通过反射把对象的所有属性进行序列化,这时,不能对这个过程进行控制。
                //var serializer = new JsonSerializer();
                //serializer.Serialize(converter._writer, model);

                converter.WriteJsonModel(model);

                var json = jsonWriter.ToString();

                return json;
            }
        }
Beispiel #28
0
 protected override void ToJson(LiteJsonWriter json)
 {
     json.WriteProperty("text", text);
     json.WriteProperty("value", value);
 }
Beispiel #29
0
 /// <summary>
 /// 子类重写此方法来实现 json 序列化的自定义。
 /// </summary>
 /// <param name="json"></param>
 protected abstract void ToJson(LiteJsonWriter json);
Beispiel #30
0
        protected override void ToJson(LiteJsonWriter json)
        {
            if (mainBlock == null) throw new ArgumentNullException("mainBlock");

            json.WritePropertyIf("layoutClass", layoutClass);
            json.WritePropertyIf("childProperty", childProperty);
            json.WriteProperty("mainBlock", mainBlock);
            json.WritePropertyIf("children", children);
            json.WritePropertyIf("surrounders", surrounders);
        }
Beispiel #31
0
        protected override void ToJson(LiteJsonWriter json)
        {
            json.WritePropertyIf("surrounderType", surrounderType);

            base.ToJson(json);
        }
Beispiel #32
0
        protected override void ToJson(LiteJsonWriter json)
        {
            if (allowBlank) { json.WriteProperty("allowBlank", allowBlank); }

            base.ToJson(json);
        }
Beispiel #33
0
 protected override void ToJson(LiteJsonWriter json)
 {
     json.WriteProperty("pageSize", pageSize);
 }
Beispiel #34
0
 protected override void ToJson(LiteJsonWriter json)
 {
     json.WriteProperty(SuccessProperty, Success.Box());
     json.WritePropertyIf(MessageProperty, Message);
 }
Beispiel #35
0
        protected override void ToJson(LiteJsonWriter json)
        {
            json.WriteProperty("text", ".");

            base.ToJson(json);
        }