Example #1
0
        /// <summary>
        /// Loads the specified settings file and deserializes values. It uses the existing
        /// settings to figure out the type to convert the strings to.
        /// </summary>
        /// <param name="filename">XmlNotepad settings xml file.</param>
        public void Load(string filename)
        {
            pfn = new PersistentFileNames(Settings.Instance.StartupPath);

            // we don't use the serializer because it's too slow to fire up.
            try
            {
                using (var r = new XmlTextReader(filename))
                {
                    if (r.IsStartElement("Settings"))
                    {
                        while (r.Read())
                        {
                            if (r.NodeType == XmlNodeType.Element)
                            {
                                string name = r.Name;
                                object o    = map[name];
                                if (o != null)
                                {
                                    object value = null;
                                    if (o is Hashtable)
                                    {
                                        ReadHashTable(r, (Hashtable)o);
                                    }
                                    else if (o is Array)
                                    {
                                        value = ReadArray(name, (Array)o, r);
                                    }
                                    else if (o is IXmlSerializable)
                                    {
                                        IXmlSerializable xs = (IXmlSerializable)o;
                                        xs.ReadXml(r);
                                    }
                                    else
                                    {
                                        string s = r.ReadString();
                                        value = ConvertToType(s, o.GetType());
                                    }
                                    if (value != null)
                                    {
                                        this[name] = value;
                                    }
                                }
                                OnChanged(name);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                // Hey, at least we tried!
                Debug.WriteLine("Load settings failed: " + ex.Message);
            }

            this.FileName = filename;
        }
Example #2
0
 public SchemaCache()
 {
     this.pfn = new PersistentFileNames(Settings.Instance.StartupPath);
 }
Example #3
0
 public SchemaCache(IServiceProvider site)
 {
     this.site = site;
     this.pfn  = new PersistentFileNames(Settings.Instance.StartupPath);
 }