using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using System.ComponentModel;
using System.Globalization;
using System.Collections.Specialized;
using System.Text.RegularExpressions;
using System.Xml.Serialization;
[XmlInclude(typeof(Enummies.BigMethods))]
[XmlInclude(typeof(Enummies.SmallMethods))]
private Enum _MethodType;
[XmlElement(Order = 1, ElementName = "MethodType")]
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DebuggerBrowsable(DebuggerBrowsableState.Never)]
public object MethodTypeObject
get { return MethodType; }
set { MethodType = (Enum)value; }
get { return _MethodType; }
set { _MethodType = value; }
public TESTCLASS(Enummies.BigMethods bigM)
public TESTCLASS(Enummies.SmallMethods smallM)
public enum BigMethods { BIG_ONE, BIG_TWO, BIG_THREE }
public enum SmallMethods { SMALL_ONE, SMALL_TWO, SMALL_THREE }
public static void Test()
Test(Enummies.BigMethods.BIG_THREE);
Test(Enummies.SmallMethods.SMALL_TWO);
public static void Test(Enum value)
Console.WriteLine("Testing: " + value);
var root = new TESTCLASS { MethodType = value };
var root2 = xml.LoadFromXml<TESTCLASS>();
var xml2 = root2.GetXml();
Assert.IsTrue(root.MethodType.Equals(root2.MethodType));
public static void Main()
Console.WriteLine("Environment version: " + Environment.Version);
public static class XmlSerializationHelper
public static T LoadFromXml<T>(this string xmlString, XmlSerializer serial = null)
serial = serial ?? new XmlSerializer(typeof(T));
T returnValue = default(T);
using (StringReader reader = new StringReader(xmlString))
object result = serial.Deserialize(reader);
public static string GetXml<T>(this T obj, bool omitStandardNamespaces)
return obj.GetXml(null, omitStandardNamespaces);
public static string GetXml<T>(this T obj, XmlSerializer serializer = null, bool omitStandardNamespaces = false)
XmlSerializerNamespaces ns = null;
if (omitStandardNamespaces)
ns = new XmlSerializerNamespaces();
using (var textWriter = new StringWriter())
var settings = new XmlWriterSettings() { Indent = true };
using (var xmlWriter = XmlWriter.Create(textWriter, settings))
(serializer ?? new XmlSerializer(obj.GetType())).Serialize(xmlWriter, obj, ns);
return textWriter.ToString();
public class AssertionFailedException : System.Exception
public AssertionFailedException() : base() { }
public AssertionFailedException(string s) : base(s) { }
public static class Assert
public static void IsTrue(bool value)
public static void IsTrue(bool value, string message)
throw new AssertionFailedException(message);