Exemplo n.º 1
0
 public static void Write(TextWriter writer, bool ownsStream, Action<JsonWriter.Item> resolver, JsonWriterOptions options = null)
 {
     JsonWriter w = new JsonWriter(writer, options);
     if (options == null) options = defaultOptions;
     resolver(w.itemWriter);
     if (ownsStream)
         writer.Close();
 }
Exemplo n.º 2
0
 private JsonWriter(TextWriter writer, JsonWriterOptions options)
 {
     objWriter = new JsonWriter.Object(this);
     arrWriter = new JsonWriter.Array(this);
     itemWriter = new JsonWriter.Item(this);
     this.writer = writer;
     this.options = options ?? defaultOptions;
     this.notfirst = new BitArray(this.options.MaxDepth + 1);
     this.current = new Property(null, false, this.options.Targets);
 }
Exemplo n.º 3
0
 public static void WriteTo(this ICollection items, System.IO.TextWriter writer, bool ownsStream, JsonWriterOptions options)
 {
     JsonWriter.Write(writer, ownsStream, iw => iw.WriteArray(items.Write), options);
 }
Exemplo n.º 4
0
 public static string ToJson(this ICollection items, JsonWriterOptions options)
 {
     var sw = new System.IO.StringWriter();
     JsonWriter.Write(sw, true, iw => iw.WriteArray(items.Write), options);
     return sw.ToString();
 }
Exemplo n.º 5
0
 public static string ToJson(this ICollection items, bool formatted = false, char formatChar = '\t', int maxDepth = JsonWriter.MAX_DEPTH, bool ignoreDirectionRestrictions = false, Propex targets = null)
 {
     JsonWriterOptions options = new JsonWriterOptions(maxDepth, formatChar, formatted, ignoreDirectionRestrictions, targets);
     return items.ToJson(options);
 }
Exemplo n.º 6
0
 public static void Write(TextWriter writer, bool ownsStream, IJsonItemWriter writableItem, JsonWriterOptions options = null)
 {
     Write(writer, ownsStream, writableItem.Write, options);
 }
Exemplo n.º 7
0
 protected ResponseAction Respond(HttpStatusCode status, IJsonItemWriter itemWriter, JsonWriterOptions options)
 {
     return r =>
     {
         r.StatusCode = (int)status;
         JsonWriter.Write(r.Output, false, itemWriter.Write, options);
     };
 }
Exemplo n.º 8
0
 protected ResponseAction Respond(HttpStatusCode status, IJsonObject jsonObject, Propex targets)
 {
     var options = new JsonWriterOptions(targets: targets, formatted: Formatted);
     return Respond(status, (IJsonItemWriter)jsonObject, options);
 }
Exemplo n.º 9
0
 protected ResponseAction OK(System.Collections.ICollection models, JsonWriterOptions options)
 {
     return r =>
     {
         r.StatusCode = (int)HttpStatusCode.OK;
         models.WriteTo(r.Output, false, options);
     };
 }
Exemplo n.º 10
0
 protected ResponseAction OK(System.Collections.ICollection models, Propex targets)
 {
     JsonWriterOptions options = new JsonWriterOptions(targets: targets, formatted: Formatted);
     return OK(models, options);
 }
Exemplo n.º 11
0
 public static string ToJson(this IDictionary items, JsonWriterOptions options)
 {
     var sw = new System.IO.StringWriter();
     JsonWriter.Write(sw, true, iw => iw.WriteObject(items.Write), options);
     return sw.ToString();
 }