Beispiel #1
0
        public override void SetValue(string Setting, string Value, bool persist = true)
        {
            //Find the element
            XElement element = FindElementByKey(Setting);

            if (element == null)
            {
                //Setting isn't stored, so create it
                element = new XElement("Setting",
                                       new XAttribute("Key", Setting),
                                       new XAttribute("Value", Value));
                document.Root.Element("Config").Add(element);
            }
            else
            {
                //Update the element
                XAttribute _value = element.Attribute("Value");
                if (_value == null)
                {
                    element.Add(new XAttribute("Key", Value));
                }
                else
                {
                    _value.Value = Value;
                }
                //Update dictionary
                settings[Setting] = Value;
            }
            if (persist)
            {
                factory.Save();
            }
        }
Beispiel #2
0
        public override void UpdateCardtype(Cardtype updated, bool persist = true)
        {
            //Find the corresponding element in the document
            XElement element = FindElementByID(updated.ID);
            //Attribute - title
            XAttribute _title = element.Attribute("Title");

            if (_title != null)
            {
                _title.Value = updated.Title;
            }
            else
            {
                element.Add(new XAttribute("Title", updated.Title));
            }
            //TODO: Change title dictionary
            //Attribute - basePath
            XAttribute _iconPath = element.Attribute("IconPath");

            if (updated.IconPath != null && !updated.IconPath.Equals(""))
            {
                if (_iconPath != null)
                {
                    _iconPath.Value = updated.IconPath;
                }
                else
                {
                    element.Add(new XAttribute("IconPath", updated.IconPath));
                }
            }
            else
            {
                if (_iconPath != null)
                {
                    _iconPath.Remove();
                }
            }
            //Ignored: ID, Game
            //Flush the file
            if (persist)
            {
                factory.Save();
            }
        }
        public override void UpdateGame(Game updated, bool persist = true)
        {
            //Find the corresponding element in the document
            XElement element = FindElementByID(updated.ID);
            //Attribute - title
            XAttribute _title = element.Attribute("Title");

            if (_title != null)
            {
                _title.Value = updated.Title;
            }
            else
            {
                element.Add(new XAttribute("Title", updated.Title));
            }
            //TODO: Change title dictionary
            //Attribute - year
            XAttribute _year = element.Attribute("Year");

            if (updated.Year > 0)
            {
                if (_year != null)
                {
                    _year.Value = Convert.ToString(updated.Year);
                }
                else
                {
                    element.Add(new XAttribute("Year", updated.Year));
                }
            }
            else
            {
                if (_year != null)
                {
                    _year.Remove();
                }
            }
            //Attribute - url
            XAttribute _url = element.Attribute("Url");

            if (updated.Url != null && !updated.Url.Equals(""))
            {
                if (_url != null)
                {
                    _url.Value = updated.Url;
                }
                else
                {
                    element.Add(new XAttribute("Url", updated.Url));
                }
            }
            else
            {
                if (_url != null)
                {
                    _url.Remove();
                }
            }
            //Attribute - publisher
            XAttribute _publisher = element.Attribute("Publisher");

            if (updated.Publisher != null && !updated.Publisher.Equals(""))
            {
                if (_publisher != null)
                {
                    _publisher.Value = updated.Publisher;
                }
                else
                {
                    element.Add(new XAttribute("Publisher", updated.Publisher));
                }
            }
            else
            {
                if (_publisher != null)
                {
                    _publisher.Remove();
                }
            }
            //Attribute - basePath
            XAttribute _basePath = element.Attribute("BasePath");

            if (updated.BasePath != null && !updated.BasePath.Equals(""))
            {
                if (_basePath != null)
                {
                    _basePath.Value = updated.BasePath;
                }
                else
                {
                    element.Add(new XAttribute("BasePath", updated.BasePath));
                }
            }
            else
            {
                if (_basePath != null)
                {
                    _basePath.Remove();
                }
            }
            //Attribute - logoPath
            XAttribute _logoPath = element.Attribute("LogoPath");

            if (updated.LogoPath != null && !updated.LogoPath.Equals(""))
            {
                if (_logoPath != null)
                {
                    _logoPath.Value = updated.LogoPath;
                }
                else
                {
                    element.Add(new XAttribute("LogoPath", updated.LogoPath));
                }
            }
            else
            {
                if (_logoPath != null)
                {
                    _logoPath.Remove();
                }
            }
            //Attribute - bannerPath
            XAttribute _bannerPath = element.Attribute("BannerPath");

            if (updated.BannerPath != null && !updated.BannerPath.Equals(""))
            {
                if (_bannerPath != null)
                {
                    _bannerPath.Value = updated.BannerPath;
                }
                else
                {
                    element.Add(new XAttribute("BannerPath", updated.BannerPath));
                }
            }
            else
            {
                if (_bannerPath != null)
                {
                    _bannerPath.Remove();
                }
            }
            //Ignored: ID, child elements
            //Flush the file
            if (persist)
            {
                factory.Save();
            }
        }
        public override void UpdateCard(Card updated, bool persist = true)
        {
            //Find the corresponding element in the document
            XElement element = FindElementByID(updated.ID);
            //Attribute - code
            XAttribute _code = element.Attribute("Code");

            if (_code != null)
            {
                _code.Value = updated.Code;
            }
            else
            {
                element.Add(new XAttribute("Code", updated.Code));
            }
            //TODO: Change dictionary
            //Attribute - title
            XAttribute _title = element.Attribute("Title");

            if (updated.Title != null && !updated.Title.Equals(""))
            {
                if (_title != null)
                {
                    _title.Value = updated.Title;
                }
                else
                {
                    element.Add(new XAttribute("Title", updated.Title));
                }
            }
            else
            {
                if (_title != null)
                {
                    _title.Remove();
                }
            }
            //Attribute - faction
            XAttribute _faction = element.Attribute("Faction");

            if (updated.Faction != null)
            {
                if (_faction != null)
                {
                    _faction.Value = Convert.ToString(updated.Faction.ID);
                }
                else
                {
                    element.Add(new XAttribute("Faction", Convert.ToString(updated.Faction.ID)));
                }
            }
            else
            {
                if (_faction != null)
                {
                    _faction.Remove();
                }
            }
            //Attribute - cardtype
            XAttribute _cardtype = element.Attribute("Cardtype");

            if (updated.Cardtype != null)
            {
                if (_cardtype != null)
                {
                    _cardtype.Value = Convert.ToString(updated.Cardtype.ID);
                }
                else
                {
                    element.Add(new XAttribute("Cardtype", Convert.ToString(updated.Cardtype.ID)));
                }
            }
            else
            {
                if (_cardtype != null)
                {
                    _cardtype.Remove();
                }
            }
            //Ignored: ID, Game
            //Flush the file
            if (persist)
            {
                factory.Save();
            }
        }
Beispiel #5
0
        public override void UpdateFaction(Faction updated, bool persist = true)
        {
            //Find the corresponding element in the document
            XElement element = FindElementByID(updated.ID);
            //Attribute - title
            XAttribute _title = element.Attribute("Title");

            if (_title != null)
            {
                _title.Value = updated.Title;
            }
            else
            {
                element.Add(new XAttribute("Title", updated.Title));
            }
            //TODO: Change title dictionary
            //Attribute - basePath
            XAttribute _iconPath = element.Attribute("IconPath");

            if (updated.IconPath != null && !updated.IconPath.Equals(""))
            {
                if (_iconPath != null)
                {
                    _iconPath.Value = updated.IconPath;
                }
                else
                {
                    element.Add(new XAttribute("IconPath", updated.IconPath));
                }
            }
            else
            {
                if (_iconPath != null)
                {
                    _iconPath.Remove();
                }
            }
            //Attribute - ColourBackground
            XAttribute _colourBackground = element.Attribute("ColourBackground");

            if (updated.ColourBackground != null && !updated.ColourBackground.Equals(""))
            {
                if (_colourBackground != null)
                {
                    _colourBackground.Value = updated.ColourBackground;
                }
                else
                {
                    element.Add(new XAttribute("ColourBackground", updated.ColourBackground));
                }
            }
            else
            {
                if (_colourBackground != null)
                {
                    _colourBackground.Remove();
                }
            }
            //Attribute - ColourText
            XAttribute _colourText = element.Attribute("ColourText");

            if (updated.ColourText != null && !updated.ColourText.Equals(""))
            {
                if (_colourText != null)
                {
                    _colourText.Value = updated.ColourText;
                }
                else
                {
                    element.Add(new XAttribute("ColourText", updated.ColourText));
                }
            }
            else
            {
                if (_colourText != null)
                {
                    _colourText.Remove();
                }
            }
            //Ignored: ID, Game, child elements
            //Flush the file
            if (persist)
            {
                factory.Save();
            }
        }