private static string GetXmlString(object obj) { if (obj == null) { throw new ArgumentNullException("obj"); } string @string; using (MemoryStream memoryStream = new MemoryStream()) { VersionedXmlBase.Serialize(memoryStream, obj); memoryStream.Seek(0L, SeekOrigin.Begin); @string = Encoding.UTF8.GetString(memoryStream.ToArray()); } return(@string); }
private static string GetBase64XmlString(object obj) { if (obj == null) { throw new ArgumentNullException("obj"); } string result; using (MemoryStream memoryStream = new MemoryStream()) { VersionedXmlBase.Serialize(memoryStream, obj); memoryStream.Seek(0L, SeekOrigin.Begin); result = Convert.ToBase64String(memoryStream.ToArray()); } return(result); }
internal static void Serialize(Stream stream, VersionedXmlBase obj) { if (stream == null) { throw new CustomSerializationException(ServerStrings.ErrorInvalidConfigurationXml, new ArgumentNullException("stream")); } if (obj == null) { throw new ArgumentNullException("obj"); } VersionedXmlBase.Serialize(stream, obj); try { stream.SetLength(stream.Position); } catch (NotSupportedException) { } }