public static T Xml <T>(this SerializationExtensionPoint <T> extensionPoint, string path) { using (var stream = File.OpenRead(path)) { return(Xml(extensionPoint, stream)); } }
public static void Xml <T>(this SerializationExtensionPoint <T> extensionPoint, string path, T value) { using (var stream = File.OpenWrite(path)) { Xml(extensionPoint, stream, value); } }
public void Type() { var extensionPoint = new SerializationExtensionPoint<object>(typeof(int)); Assert.Null(extensionPoint.ExtendedValue); Assert.Same(typeof(int), extensionPoint.ExtendedType); }
public void Type() { var extensionPoint = new SerializationExtensionPoint <object>(typeof(int)); Assert.Null(extensionPoint.ExtendedValue); Assert.Same(typeof(int), extensionPoint.ExtendedType); }
public void Instance() { int instance = 1; var extensionPoint = new SerializationExtensionPoint<int>(instance); Assert.Equal(instance, extensionPoint.ExtendedValue); Assert.Equal(typeof(int), extensionPoint.ExtendedType); }
public void Instance() { int instance = 1; var extensionPoint = new SerializationExtensionPoint <int>(instance); Assert.Equal(instance, extensionPoint.ExtendedValue); Assert.Equal(typeof(int), extensionPoint.ExtendedType); }
public static T Binary <T>(this SerializationExtensionPoint <T> extensionPoint, byte[] data) { var serializer = new BinaryFormatter(); using (var stream = new MemoryStream(data)) { return((T)serializer.Deserialize(stream)); } }
public static void Binary <T>(this SerializationExtensionPoint <T> extensionPoint, Stream output) { if (extensionPoint.ExtendedValue != null) { var serializer = new BinaryFormatter(); serializer.Serialize(output, extensionPoint.ExtendedValue); output.Flush(); } }
public static T Xml <T>(this SerializationExtensionPoint <T> extensionPoint) { using (var stream = new MemoryStream()) { Xml(extensionPoint, stream, extensionPoint.ExtendedValue); stream.Position = 0; return(Xml(extensionPoint, stream)); } }
public static T Binary <T>(this SerializationExtensionPoint <T> extensionPoint) { var serializer = new BinaryFormatter(); using (var stream = new MemoryStream()) { serializer.Serialize(stream, extensionPoint.ExtendedValue); stream.Position = 0; var newInstance = (T)serializer.Deserialize(stream); return(newInstance); } }
public static T DataContract <T>(this SerializationExtensionPoint <T> extensionPoint) { var serializer = new DataContractSerializer(extensionPoint.ExtendedType); using (var stream = new MemoryStream()) { serializer.WriteObject(stream, extensionPoint.ExtendedValue); stream.Position = 0; var newInstance = (T)serializer.ReadObject(stream); return(newInstance); } }
public static void Xml <T>(this SerializationExtensionPoint <T> extensionPoint, Stream stream, T value) { var serializer = new XmlSerializer(extensionPoint.ExtendedType); serializer.Serialize(stream, value); }
public static T Xml <T>(this SerializationExtensionPoint <T> extensionPoint, Stream stream) { var serializer = new XmlSerializer(extensionPoint.ExtendedType); return((T)serializer.Deserialize(stream)); }