Пример #1
0
 /// <summary>
 /// Write a literal value in JSON Light format.
 /// </summary>
 /// <param name="model">EDM Model to use for validation and type lookups.</param>
 /// <param name="messageWriterSettings">Settings to use when writing.</param>
 /// <param name="textWriter">TextWriter to use as the output for the value.</param>
 /// <param name="writeValue">Delegate to use to actually write the value.</param>
 private static void WriteJsonLightLiteral(IEdmModel model, ODataMessageWriterSettings messageWriterSettings, TextWriter textWriter, Action<ODataJsonLightValueSerializer> writeValue)
 {
     // Calling dispose since it's the right thing to do, but when created from a custom-built TextWriter
     // the output context Dispose will not actually dispose anything, it will just cleanup itself.
     using (ODataJsonLightOutputContext jsonOutputContext = new ODataJsonLightOutputContext(ODataFormat.Json, textWriter, messageWriterSettings, model))
     {
         ODataJsonLightValueSerializer jsonLightValueSerializer = new ODataJsonLightValueSerializer(jsonOutputContext);
         writeValue(jsonLightValueSerializer);
         jsonLightValueSerializer.AssertRecursionDepthIsZero();
     }
 }