Example #1
0
            public ISettingsNode?TryGetSubNode(string nodeNameOrPath)
            {
                FileSettingsNode?result = null;

                XElement?subElement = this.GetSubNodeElement(nodeNameOrPath, false);

                if (subElement != null)
                {
                    result = new FileSettingsNode(subElement, this);
                }

                return(result);
            }
Example #2
0
        public FileSettingsStore()
        {
            foreach (string fileName in GetPotentialFileNames())
            {
                // Make sure the file exists and isn't zero length.  If a process was killed while saving data,
                // then the settings store file may be empty.  If so, we'll pretend it isn't there.
                FileInfo file = new(fileName);
                if (file.Exists && file.Length > 0)
                {
                    this.root = XElement.Load(fileName);
                    break;
                }
            }

            if (this.root == null)
            {
                this.root = FileSettingsNode.CreateNodeElement(ApplicationInfo.ApplicationName);
            }

            this.RootNode = new FileSettingsNode(this.root, null);
        }