public static void Main()
var thingy = Thingy.CreateValueElem(5);
Console.WriteLine(thingy.Name);
Console.WriteLine(thingy.Value);
var thingy2 = Thingy.CreateValueElemRefactor<int>(5);
Console.WriteLine(thingy2.Name);
Console.WriteLine(thingy2.Value);
public static class Thingy
public static XElement CreateValueElem(int value)
return new XElement("value", new XElement("int", value));
public static XElement CreateValueElem(decimal value)
return new XElement("value", new XElement("decimal", value));
public static XElement CreateValueElem(long value)
return new XElement("value", new XElement("long", value));
public static XElement CreateValueElem(bool value)
return new XElement("value", new XElement("boolean", value ? 1 : 0));
public static XElement CreateValueElem(string value)
return new XElement("value", new XElement("string", value));
public static XElement CreateValueElemRefactor<T>(T value)
return new XElement("value", new XElement(typeof(T).Name.ToLower(), value));