Exemple #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();
 }
Exemple #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);
 }
 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);
 }
 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();
 }
 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);
 }
Exemple #6
0
 public static void Write(TextWriter writer, bool ownsStream, IJsonItemWriter writableItem, JsonWriterOptions options = null)
 {
     Write(writer, ownsStream, writableItem.Write, options);
 }
Exemple #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);
     };
 }
Exemple #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);
 }
Exemple #9
0
 protected ResponseAction OK(System.Collections.ICollection models, JsonWriterOptions options)
 {
     return r =>
     {
         r.StatusCode = (int)HttpStatusCode.OK;
         models.WriteTo(r.Output, false, options);
     };
 }
Exemple #10
0
 protected ResponseAction OK(System.Collections.ICollection models, Propex targets)
 {
     JsonWriterOptions options = new JsonWriterOptions(targets: targets, formatted: Formatted);
     return OK(models, options);
 }
 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();
 }