WIP
DirectOutput framework for virtual pinball cabinets WIP
Go to:
Overview 
ObjectExtensions.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Xml.Serialization;
6 using System.IO;
7 using System.Xml;
8 
9 public static class ObjectExtensions
10 {
17  public static string XmlSerialize<T>(this T ObjectToSerialize)
18  {
19  Type RealType = ObjectToSerialize.GetType();
20 
21  string Xml = "";
22  using (MemoryStream ms = new MemoryStream())
23  {
24 
25  XmlSerializerNamespaces Namespaces = new XmlSerializerNamespaces();
26  Namespaces.Add(string.Empty, string.Empty);
27 
28  new XmlSerializer(RealType).Serialize(ms, ObjectToSerialize,Namespaces);
29  ms.Position = 0;
30  using (StreamReader sr = new StreamReader(ms, Encoding.Default))
31  {
32  Xml = sr.ReadToEnd();
33  sr.Dispose();
34  }
35  }
36 
37  return Xml;
38 
39  }
40 
41 
42 
43 
44 }
45