CreateJsonWriter() public static method

public static CreateJsonWriter ( System stream ) : System.Xml.XmlDictionaryWriter
stream System
return System.Xml.XmlDictionaryWriter
Beispiel #1
0
 public void WriteObject(Stream stream, object graph)
 {
     using (var writer = JsonReaderWriterFactory.CreateJsonWriter(stream))
     {
         WriteObject(writer, graph);
     }
 }
        public override void WriteObject(Stream stream, object graph)
        {
            CheckNull(stream, "stream");
            XmlDictionaryWriter jsonWriter = JsonReaderWriterFactory.CreateJsonWriter(stream, Encoding.UTF8, false); //  ownsStream

            WriteObject(jsonWriter, graph);
            jsonWriter.Flush();
        }
        public override void WriteObject(Stream stream, object graph)
        {
            XmlObjectSerializer.CheckNull(stream, "stream");
            XmlDictionaryWriter writer = JsonReaderWriterFactory.CreateJsonWriter(stream, Encoding.UTF8, false);

            this.WriteObject(writer, graph);
            writer.Flush();
        }
Beispiel #4
0
        public override void WriteObject(Stream stream, object?graph)
        {
            ArgumentNullException.ThrowIfNull(stream);

            XmlDictionaryWriter jsonWriter = JsonReaderWriterFactory.CreateJsonWriter(stream, Encoding.UTF8, false); //  ownsStream

            WriteObject(jsonWriter, graph);
            jsonWriter.Flush();
        }
Beispiel #5
0
 public void WriteObject(Stream stream, object graph)
 {
     using (var writer = JsonReaderWriterFactory.CreateJsonWriter(stream)) {
         try {
             writer.WriteStartElement("root");
             new JsonSerializationWriter(this, writer, type, false).WriteObjectContent(graph, true, false);
             writer.WriteEndElement();
         } catch (FieldAccessException fae) {
             throw new SecurityException("Serialization has failed", fae);
         } catch (MethodAccessException mae) {
             throw new SecurityException("Serialization has failed", mae);
         } catch (NotImplementedException) {
             throw;
         } catch (InvalidDataContractException) {
             throw;
         } catch (Exception ex) {
             throw new SerializationException(String.Format("There was an error during serialization for object of type {0}", graph != null ? graph.GetType() : null), ex);
         }
     }
 }
Beispiel #6
0
 public override void WriteObject(Stream stream, object graph)
 {
     using (var xw = JsonReaderWriterFactory.CreateJsonWriter(stream))
         WriteObject(xw, graph);
 }
Beispiel #7
0
 public static XmlDictionaryWriter CreateJsonWriter(Stream stream, Encoding encoding)
 {
     return(JsonReaderWriterFactory.CreateJsonWriter(stream, encoding, true));
 }