public ExtensionDataObjectSerializationProxy(SerializationInfo info, StreamingContext context) { var xml = (string)info.GetValue("ExtensionData", typeof(string)); if (!string.IsNullOrEmpty(xml)) { var wrapper = DataContractSerializerHelper.LoadFromXML <ExtensionDataObjectSerializationContractProxy>(xml); this.ExtensionData = (wrapper == null ? null : wrapper.ExtensionData); } }
public static void Test() { var test = new TestConfiguration(); Debug.WriteLine("\nTesting Xmlserializer..."); var xml = XmlSerializationHelper.GetXml(test); using (new SetValue <bool>(TestConfiguration.ShowDebugInformation, true)) { var testFromXml = XmlSerializationHelper.LoadFromXML <TestConfiguration>(xml); Debug.WriteLine("XmlSerializer result: " + testFromXml.ToString()); } Debug.WriteLine("\nTesting Json.NET..."); var json = JsonConvert.SerializeObject(test, Formatting.Indented); using (new SetValue <bool>(TestConfiguration.ShowDebugInformation, true)) { var testFromJson = JsonConvert.DeserializeObject <TestConfiguration>(json); Debug.WriteLine("Json.NET result: " + testFromJson.ToString()); } Debug.WriteLine("\nTesting DataContractSerializer..."); var contractXml = DataContractSerializerHelper.GetXml(test); using (new SetValue <bool>(TestConfiguration.ShowDebugInformation, true)) { var testFromContractXml = DataContractSerializerHelper.LoadFromXML <TestConfiguration>(contractXml); Debug.WriteLine("DataContractSerializer result: " + testFromContractXml.ToString()); } Debug.WriteLine("\nTesting BinaryFormatter..."); var binary = BinaryFormatterHelper.ToBase64String(test); using (new SetValue <bool>(TestConfiguration.ShowDebugInformation, true)) { var testFromBinary = BinaryFormatterHelper.FromBase64String <TestConfiguration>(binary); Debug.WriteLine("BinaryFormatter result: " + testFromBinary.ToString()); } Debug.WriteLine("\nTesting JavaScriptSerializer..."); var javaScript = new JavaScriptSerializer().Serialize(test); using (new SetValue <bool>(TestConfiguration.ShowDebugInformation, true)) { var testFromJavaScript = new JavaScriptSerializer().Deserialize <TestConfiguration>(javaScript); Debug.WriteLine("JavaScriptSerializer result: " + testFromJavaScript.ToString()); } }