public static bool Create(UpdateConfiguration config)
        {
            bool result = false;

            Remove();

            if (config != null)
            {
                var xml = CreateDocument(config);
                XML_Functions.WriteDocument(xml, CONFIG_FILEPATH);
            }

            return(result);
        }
        public static bool Create(UpdateConfiguration config)
        {
            bool result = false;

            Remove();

            if (config != null)
            {
                var xml = CreateDocument(config);
                XML_Functions.WriteDocument(xml, CONFIG_FILEPATH);
            }

            return result;
        }
        public static UpdateConfiguration Read()
        {
            var result = new UpdateConfiguration();

            var xml = XML_Functions.ReadDocument(CONFIG_FILEPATH);
            if (xml != null)
            {
                foreach (XmlNode node in xml.DocumentElement.ChildNodes)
                {
                    if (node.NodeType == XmlNodeType.Element)
                    {
                        if (node.InnerText != "")
                        {
                            Type Settings = typeof(UpdateConfiguration);
                            PropertyInfo info = Settings.GetProperty(node.Name);

                            if (info != null)
                            {
                                Type t = info.PropertyType;
                                info.SetValue(result, Convert.ChangeType(node.InnerText, t), null);
                            }
                        }
                    }
                }
            }

            return result;
        }
        private static XmlDocument CreateDocument(UpdateConfiguration config)
        {
            var result = new XmlDocument();

            XmlNode docNode = result.CreateXmlDeclaration("1.0", "UTF-8", null);
            result.AppendChild(docNode);

            XmlNode root = result.CreateElement("UpdateConfiguration");
            result.AppendChild(root);

            foreach (var info in typeof(UpdateConfiguration).GetProperties())
            {
                XmlNode node = result.CreateElement(info.Name);
                var val = info.GetValue(config, new object[] { });
                if (val != null) node.InnerText = val.ToString();
                root.AppendChild(node);
            }

            return result;
        }
Пример #5
0
        private void Save()
        {
            var config = new UpdateConfiguration();

            config.UpdateCheckInterval = GetMinutesFromMilliseconds(UpdateCheckInterval);

            config.Enabled = UpdatesEnabled;

            UpdateConfiguration.Create(config);
        }