public void WriteAsJson(TextWriter output, string mode, ISerializationAnnotator annotator, bool pretty = false, int level = 0) { if (string.IsNullOrWhiteSpace(mode)) { mode = "admin"; } var jw = new JsonWriter(output, pretty: pretty, level: level); jw.OpenObject(); jw.WriteProperty("name", Name); jw.WriteProperty("isauth", IsAuthenticated); jw.WriteProperty("authtype", AuthenticationType); jw.WriteProperty("isadmin", IsAdmin, true); jw.WriteProperty("isguest", IsGuest, true); jw.WriteProperty("iserror", IsError, true); jw.WriteProperty("state", State, true); jw.WriteProperty("stateinfo", StateInfo, true); if (null != Token) { jw.OpenProperty("token"); jw.WriteNative(Token.stringify(mode)); jw.CloseProperty(); } if (null != User) { jw.OpenProperty("user"); jw.WriteNative(User.stringify(mode)); jw.CloseProperty(); } jw.CloseObject(); }
public void WriteAsJson(TextWriter output, string mode, ISerializationAnnotator annotator, bool pretty = false, int level = 0) { var jw = new JsonWriter(output, pretty: pretty, level: level); jw.OpenObject(); jw.WriteProperty(nameof(ok), ok); jw.WriteProperty(nameof(message), message, true); jw.WriteProperty(nameof(error), error, true); jw.WriteProperty(nameof(data), data, true); jw.CloseObject(); }
public void WriteAsJson(TextWriter output, string mode, ISerializationAnnotator annotator, bool pretty = false, int level = 0) { var jw = new JsonWriter(output, pretty: pretty, level: level); jw.OpenObject(); jw.WriteProperty("id", Id); jw.WriteProperty("dataonly", DataOnly); jw.WriteProperty("format", Format); jw.WriteProperty("query", Query); jw.WriteProperty("json", this.Json); jw.WriteProperty("standalone", Standalone); jw.WriteProperty("parameters", this.Parameters); jw.WriteProperty("flags", this.Flags); jw.CloseObject(); }
public virtual void WriteExtensions(JsonWriter writer, string mode, ISerializationAnnotator annotator) { }
public void WriteAsJson(TextWriter output, string usermode, ISerializationAnnotator annotator, bool pretty = false, int level = 0) { UserSerializer.WriteJson(this, output, usermode); }
public virtual void WriteExtensions(JsonWriter writer, string mode, ISerializationAnnotator annotator) { }
public void WriteAsJson(TextWriter output, string usermode, ISerializationAnnotator annotator, bool pretty = false, int level = 0) { UserSerializer.WriteJson(this, output, usermode); }
void IJsonSerializable.WriteAsJson(TextWriter output, string mode, ISerializationAnnotator annotator, bool pretty = false, int level = 0) { WriteJson(output, mode, pretty, level); }
public void WriteAsJson(TextWriter output, string mode, ISerializationAnnotator annotator, bool pretty = false, int level = 0) { var jw = new JsonWriter(output, pretty: pretty, level: level); jw.OpenObject(); if (0 != Meta.Count) { jw.WriteProperty("meta", Meta); } if (null == Parent && null != Collectors && 0 != Collectors.Length) { jw.WriteProperty("collectors", Collectors.OfType <ICollector>().Select( c => new { key = c.Key, name = c.Name ?? c.Key, shortname = c.ShortName ?? c.Name ?? c.Key, group = c.Group, condition = c.Condition }.jsonify()).ToArray()); } if (null == Parent && null != Routs && 0 != Routs.Length) { jw.WriteProperty("routs", Routs.Select( c => new { key = c.Key ?? "nokey", name = c.Name ?? c.Key, shortname = c.ShortName ?? c.Name ?? c.Key, level = c.Level, parent = null == c.Parent ? "" : c.Parent.Key, }.jsonify()).ToArray()); } jw.WriteProperty("id", Id); jw.WriteProperty("isbucket", IsBucket); if (null != RouteKey) { jw.WriteProperty("key", RouteKey.Key); jw.WriteProperty("name", RouteKey.Name); jw.WriteProperty("sortkey", RouteKey.SortKey); jw.WriteProperty("comment", RouteKey.Comment); } jw.OpenProperty("values"); jw.OpenArray(); foreach (var value in Values) { jw.WriteObject(new { key = value.Key, value = value.Value }); } jw.CloseArray(); jw.CloseProperty(); if (null != _children && 0 != _children.Count) { jw.OpenProperty("aggs"); jw.OpenArray(); foreach (var node in Children) { jw.WriteObject(node.Value); } jw.CloseArray(); jw.CloseProperty(); } jw.CloseObject(); }
public override void WriteExtensions(JsonWriter writer, string mode, ISerializationAnnotator annotator) { writer.WriteProperty("myfield", MyField); }
public void WriteAsJson(TextWriter output, string mode, ISerializationAnnotator annotator, bool pretty = false, int level = 0) { var jw = new JsonWriter(output,pretty:pretty,level:level); jw.OpenObject(); if (0 != Meta.Count) { jw.WriteProperty("meta",Meta); } if (null == Parent && null != Collectors && 0!=Collectors.Length) { jw.WriteProperty("collectors", Collectors.OfType<ICollector>().Select( c => new { key = c.Key, name = c.Name ?? c.Key, shortname = c.ShortName ?? c.Name ?? c.Key, group = c.Group, condition = c.Condition }.jsonify()).ToArray()); } if (null == Parent && null != Routs && 0 != Routs.Length) { jw.WriteProperty("routs", Routs.Select( c => new { key = c.Key ?? "nokey", name = c.Name ?? c.Key, shortname = c.ShortName ?? c.Name ?? c.Key, level = c.Level, parent = null == c.Parent ? "" : c.Parent.Key, }.jsonify()).ToArray()); } jw.WriteProperty("id",Id); jw.WriteProperty("isbucket",IsBucket); if (null != RouteKey) { jw.WriteProperty("key",RouteKey.Key); jw.WriteProperty("name",RouteKey.Name); jw.WriteProperty("sortkey",RouteKey.SortKey); jw.WriteProperty("comment",RouteKey.Comment); } jw.OpenProperty("values"); jw.OpenArray(); foreach (var value in Values) { jw.WriteObject(new {key=value.Key,value=value.Value}); } jw.CloseArray(); jw.CloseProperty(); if (null != _children && 0 != _children.Count) { jw.OpenProperty("aggs"); jw.OpenArray(); foreach (var node in Children) { jw.WriteObject(node.Value); } jw.CloseArray(); jw.CloseProperty(); } jw.CloseObject(); }
public void WriteAsJson(TextWriter output, string mode, ISerializationAnnotator annotator, bool pretty = false, int level = 0) { var writer = new JsonWriter(output, pretty: pretty, level: level); writer.OpenObject(); writer.WriteProperty("total", Total, true); writer.WriteProperty("offset", OffSet, true); writer.WriteProperty("size", Size, true); writer.WriteProperty("count", Count, true); writer.WriteProperty("page", Page, true); writer.WriteProperty("pagecount", PageCount, true); writer.WriteProperty("islastpage", IsLastPage, true); writer.WriteProperty("nochange", NoChange, true); writer.WriteProperty("hash", Hash, true); writer.WriteProperty("timestamp", Timestamp, true); writer.WriteProperty("status", Status, true); writer.WriteProperty("ok", Ok); writer.WriteProperty("message", Message, true); if (null != Error) { writer.OpenProperty("error"); writer.OpenObject(); writer.WriteProperty("type", Error.GetType().Name); writer.WriteProperty("message", Error.Message); writer.WriteProperty("stack", Error.StackTrace); writer.CloseObject(); writer.CloseProperty(); } if (null != DebugInfo && 0 != DebugInfo.Count) { writer.WriteProperty("debug", DebugInfo); } if (null != Custom && 0 != Custom.Count) { writer.WriteProperty("custom", Custom); } var mainitems = GetMainItems(); if (null != mainitems) { writer.OpenProperty("items"); writer.OpenArray(); foreach (var item in mainitems) { writer.WriteObject(item, mode); } writer.CloseArray(); writer.CloseProperty(); var native = GetNative(); if (null != native) { writer.OpenProperty("native"); writer.OpenArray(); foreach (var item in native) { writer.WriteObject(item, mode); } writer.CloseArray(); writer.CloseProperty(); } } writer.CloseObject(); }
public void WriteAsJson(TextWriter output, string mode, ISerializationAnnotator annotator, bool pretty = false, int level = 0) { if (string.IsNullOrWhiteSpace(mode)) { mode = "admin"; } var jw = new JsonWriter(output,pretty:pretty,level:level); jw.OpenObject(); jw.WriteProperty("name",Name); jw.WriteProperty("isauth",IsAuthenticated); jw.WriteProperty("authtype",AuthenticationType); jw.WriteProperty("isadmin",IsAdmin,true); jw.WriteProperty("isguest",IsGuest,true); jw.WriteProperty("iserror",IsError,true); jw.WriteProperty("state",State,true); jw.WriteProperty("stateinfo",StateInfo,true); if (null != Token) { jw.OpenProperty("token"); jw.WriteNative(Token.stringify(mode)); jw.CloseProperty(); } if (null != User) { jw.OpenProperty("user"); jw.WriteNative(User.stringify(mode)); jw.CloseProperty(); } jw.CloseObject(); }