Exemple #1
0
 internal void SerializeInner <TObject>(TObject obj, WriteMode writeMode = WriteMode.Overwrite)
 {
     ApiCallSource.AssertAccess(Permissions, Access.Write);
     if (writeMode == WriteMode.Overwrite)
     {
         SharedStream.Seek(0);
         SharedStream.SetLength(0);
     }
     else
     {
         SharedStream.Seek(0, SeekOrigin.End);
     }
     SharedStream.WriteLine(JsonConvert.SerializeObject(obj, Formatting.Indented));
 }
Exemple #2
0
        internal void SerializeInner <TObject>(TObject obj, WriteMode writeMode = WriteMode.Overwrite)
        {
            ApiCallSource.AssertAccess(Permissions, Access.Write);
            if (writeMode == WriteMode.Overwrite)
            {
                SharedStream.Seek(0);
                SharedStream.SetLength(0);
            }
            else
            {
                SharedStream.Seek(0, SeekOrigin.End);
            }

            using (var writer = new StringWriter())
            {
                new XmlSerializer(typeof(TObject)).Serialize(writer, obj);
                SharedStream.WriteLine(writer.ToString());
            }
        }