/// <summary> /// Serializes GameProfile class to a GameProfile.xml file. /// </summary> /// <param name="profile"></param> private static void SerializeGameProfile(GameProfile profile, string filename = "") { var serializer = new XmlSerializer(profile.GetType()); using (var writer = XmlWriter.Create(filename, new XmlWriterSettings { Indent = true })) { serializer.Serialize(writer, profile); } }
public static void PrintGameProfile(GameProfile profile) { PropertyInfo[] _props = typeof(GameProfile).GetProperties(); string[] properties = _props.Select(x => x.Name.ToString()).ToArray(); foreach (PropertyDescriptor prop in TypeDescriptor.GetProperties(profile)) { Type t = profile.GetType(); PropertyInfo p = t.GetProperty(prop.Name); string value = (string)p.GetValue(profile, null); System.Console.WriteLine(" {0, 12} | {1,12}", prop.Name, value); } }