Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Xml;
- using System.Configuration;
- using System.Xml.Serialization;
- using System.Xml.Schema;
- using System.IO;
- using System.Globalization;
- class Clobals
- {
- public static void Main (string[] args)
- {
- Settings.Default.WindowPositions = new WindowPositionList ();
- //Settings.Default.Save ();
- Console.WriteLine(SerializedValue(Settings.Default.WindowPositions));
- }
- public static string SerializedValue(object propertyValue)
- {
- XmlSerializer serializer = new XmlSerializer (propertyValue.GetType ());
- using (StringWriter stream = new StringWriter(CultureInfo.InvariantCulture))
- {
- var settings = new XmlWriterSettings();
- settings.OmitXmlDeclaration = true;
- using (var writer = XmlWriter.Create (stream, settings))
- {
- var emptyNamepsaces = new XmlSerializerNamespaces(new[] { XmlQualifiedName.Empty });
- serializer.Serialize (writer, propertyValue, emptyNamepsaces);
- } // writer.Flush happens here
- var serializedValue = stream.ToString ();
- return serializedValue;
- }
- }
- }
- internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
- {
- private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized (new Settings ())));
- public static Settings Default {
- get {
- return defaultInstance;
- }
- }
- [global::System.Configuration.UserScopedSettingAttribute ()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute ()]
- public WindowPositionList WindowPositions {
- get {
- return ((WindowPositionList)(this ["WindowPositions"]));
- }
- set {
- this ["WindowPositions"] = value;
- }
- }
- }
- [Serializable]
- public class WindowPositionList : IXmlSerializable
- {
- public XmlSchema GetSchema ()
- {
- return null;
- }
- public void ReadXml (XmlReader reader)
- {
- reader.ReadStartElement ("WindowPositions");
- reader.ReadEndElement ();
- }
- public void WriteXml (XmlWriter writer)
- {
- writer.WriteStartElement ("WindowPositions");
- writer.WriteEndElement ();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement