Exemplo n.º 1
0
        public SettingsManager(String pSourceFile, IStateOwner pOwner)
        {
            _Owner      = pOwner;
            pLoadedFile = pSourceFile;
            if (File.Exists(pSourceFile))
            {
                XDocument xdoc     = XDocument.Load(pSourceFile);
                var       RootNode = xdoc.Root;

                if (RootNode.Name == "Settings")
                {
                    //old settings, add those as the default.
                    StandardSettings DefaultSettings = new StandardSettings(RootNode);
                    DefaultSettings.SetOwner(this);
                    AllSettings.Add("Default", DefaultSettings);
                }
                else if (RootNode.Name == "SettingsGroups")
                {
                    foreach (var groupnode in RootNode.Elements("SettingsGroup"))
                    {
                        String           sGroupName   = groupnode.Attribute("Name").Value;
                        XElement         DataNode     = groupnode.Element("Data");
                        StandardSettings SettingsData = new StandardSettings(DataNode);
                        SettingsData.SetOwner(this);
                        AllSettings.Add(sGroupName, SettingsData);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public StandardSettings GetSettings(String pHandler = "Default")
        {
            if (!AllSettings.ContainsKey(pHandler))
            {
                var buildsettings = new StandardSettings();
                buildsettings.SetOwner(this);
                AllSettings.Add(pHandler, buildsettings);
            }

            return(AllSettings[pHandler]);
        }