public void ctor_StringBuilder_IFormatProvider_Encoding() { using (var obj = new EncodedStringWriter(new StringBuilder(), CultureInfo.InvariantCulture, Encoding.UTF8)) { Assert.NotNull(obj); } }
public void ctor_StringBuilder_Encoding() { using (var obj = new EncodedStringWriter(new StringBuilder(), Encoding.UTF8)) { Assert.NotNull(obj); } }
public void ctor_Encoding() { using (var obj = new EncodedStringWriter(Encoding.UTF8)) { Assert.NotNull(obj); } }
public void prop_Encoding_get() { var expected = Encoding.UTF8; Encoding actual; using (var obj = new EncodedStringWriter(new StringBuilder(), CultureInfo.InvariantCulture, expected)) { actual = obj.Encoding; } Assert.Equal(expected, actual); }
public static IXPathNavigable XmlSerialize(this object value) #endif { if (null == value) { throw new ArgumentNullException("value"); } var result = new XmlDocument(); var buffer = new StringBuilder(); var exception = value as Exception; #if NET20 if (ObjectExtensionMethods.IsNotNull(exception)) #else if (exception.IsNotNull()) #endif { using (var stream = new MemoryStream()) { new SoapFormatter().Serialize(stream, value); stream.Seek(0, SeekOrigin.Begin); using (var reader = new StreamReader(stream)) { buffer.Append(reader.ReadToEnd()); } } } else { using (TextWriter writer = new EncodedStringWriter(buffer, CultureInfo.InvariantCulture, Encoding.UTF8)) { XmlSerializerNamespaces namespaces; var obj = value as IXmlSerializerNamespaces; if (null == obj) { namespaces = new XmlSerializerNamespaces(); namespaces.Add(string.Empty, string.Empty); } else { namespaces = obj.XmlNamespaceDeclarations; } new XmlSerializer(value.GetType()).Serialize(writer, value, namespaces); } } result.LoadXml(buffer.ToString()); return result; }