⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 updateinfo.cs

📁 破解的飞信源代码
💻 CS
字号:
namespace Imps.Client.Pc
{
    using Imps.Client.Core;
    using Imps.Utils;
    using System;
    using System.IO;
    using System.Xml;

    internal class UpdateInfo : EventArgs
    {
        private DateTime buildTime;
        private XmlDocument config;
        private string[] details;
        private string downloadURL;
        private string hashCode;
        private long size;
        private string targetVersion;
        private UpdateType type;

        internal UpdateInfo()
        {
            this.downloadURL = string.Empty;
            this.size = -2147483648;
            this.hashCode = string.Empty;
            this.type = UpdateType.optional;
            this.buildTime = Imps.Client.Core.FixedClientSetting.Instance.BuildDate;
            this.targetVersion = HttpWebRequestHelper.UrlEncode(Imps.Client.Core.FixedClientSetting.Instance.Version);
        }

        internal UpdateInfo(Stream configStream) : this()
        {
            this.config = new XmlDocument();
            this.config.Load(configStream);
            XmlElement element = this.config["LiveUpdate"];
            if (element == null)
            {
                throw new LiveUpdateException("配置文件 格式错误,LiveUpdate 节点不存在");
            }
            XmlElement element2 = element["Type"];
            if (element2 == null)
            {
                throw new LiveUpdateException("配置文件 格式错误,Type 节点不存在");
            }
            try
            {
                this.type = (UpdateType) Enum.Parse(typeof(UpdateType), element2.InnerText, true);
            }
            catch
            {
            }
            XmlElement element3 = element["BuildTime"];
            if (element2 == null)
            {
                throw new LiveUpdateException("配置文件 格式错误,BuildTime 节点不存在");
            }
            try
            {
                DateTime.TryParse(element3.InnerText, ref this.buildTime);
            }
            catch
            {
                this.buildTime = DateTime.Now;
            }
            XmlElement element4 = element["TargetVersion"];
            if (element2 == null)
            {
                throw new LiveUpdateException("配置文件 格式错误,TargetVersion 节点不存在");
            }
            this.targetVersion = element4.InnerText;
            XmlElement element5 = element["DownloadURL"];
            if (element2 == null)
            {
                throw new LiveUpdateException("配置文件 格式错误,DownloadURL 节点不存在");
            }
            this.downloadURL = element5.InnerText.Trim();
            XmlElement element6 = element["Size"];
            if (element2 == null)
            {
                throw new LiveUpdateException("配置文件 格式错误,Size 节点不存在");
            }
            try
            {
                long.TryParse(element6.InnerText, ref this.size);
            }
            catch
            {
                this.size = 0;
            }
            XmlElement element7 = element["HashCode"];
            if (element2 == null)
            {
                throw new LiveUpdateException("配置文件 格式错误,HashCode 节点不存在");
            }
            this.hashCode = element7.InnerText.Trim();
            XmlElement element8 = element["Details"];
            if (element2 == null)
            {
                throw new LiveUpdateException("配置文件 格式错误,Details 节点不存在");
            }
            this.details = new string[element8.ChildNodes.Count];
            for (int i = 0; i < element8.ChildNodes.Count; i++)
            {
                XmlNode node = element8.ChildNodes[i];
                this.details[i] = node.InnerText;
            }
        }

        internal UpdateInfo(string configFile) : this()
        {
            if (File.Exists(configFile))
            {
                this.config = new XmlDocument();
                this.config.Load(configFile);
                XmlElement element = this.config["LiveUpdate"];
                if (element == null)
                {
                    throw new LiveUpdateException("配置文件 " + configFile + " 格式错误,LiveUpdate 节点不存在");
                }
                XmlElement element2 = element["Type"];
                if (element2 == null)
                {
                    throw new LiveUpdateException("配置文件 " + configFile + " 格式错误,Type 节点不存在");
                }
                try
                {
                    this.type = (UpdateType) Enum.Parse(typeof(UpdateType), element2.InnerText, true);
                }
                catch
                {
                }
                XmlElement element3 = element["BuildTime"];
                if (element2 == null)
                {
                    throw new LiveUpdateException("配置文件 " + configFile + " 格式错误,BuildTime 节点不存在");
                }
                try
                {
                    DateTime.TryParse(element3.InnerText, ref this.buildTime);
                }
                catch
                {
                    this.buildTime = DateTime.Now;
                }
                XmlElement element4 = element["TargetVersion"];
                if (element2 == null)
                {
                    throw new LiveUpdateException("配置文件 " + configFile + " 格式错误,TargetVersion 节点不存在");
                }
                this.targetVersion = element4.InnerText;
                XmlElement element5 = element["DownloadURL"];
                if (element2 == null)
                {
                    throw new LiveUpdateException("配置文件 " + configFile + " 格式错误,DownloadURL 节点不存在");
                }
                this.downloadURL = element5.InnerText.Trim();
                XmlElement element6 = element["Size"];
                if (element2 == null)
                {
                    throw new LiveUpdateException("配置文件 " + configFile + " 格式错误,Size 节点不存在");
                }
                try
                {
                    long.TryParse(element6.InnerText, ref this.size);
                }
                catch
                {
                    this.size = 0;
                }
                XmlElement element7 = element["HashCode"];
                if (element2 == null)
                {
                    throw new LiveUpdateException("配置文件 " + configFile + " 格式错误,HashCode 节点不存在");
                }
                this.hashCode = element7.InnerText.Trim();
                XmlElement element8 = element["Details"];
                if (element2 == null)
                {
                    throw new LiveUpdateException("配置文件 " + configFile + " 格式错误,Details 节点不存在");
                }
                this.details = new string[element8.ChildNodes.Count];
                for (int i = 0; i < element8.ChildNodes.Count; i++)
                {
                    XmlNode node = element8.ChildNodes[i];
                    this.details[i] = node.InnerText;
                }
            }
        }

        internal void Save(string configFile)
        {
            if (this.config != null)
            {
                this.config.Save(configFile);
            }
        }

        public DateTime BuildTime
        {
            get
            {
                return this.buildTime;
            }
            set
            {
                this.buildTime = value;
            }
        }

        public string[] Details
        {
            get
            {
                return this.details;
            }
            set
            {
                this.details = value;
            }
        }

        public string DownloadURL
        {
            get
            {
                return this.downloadURL;
            }
            set
            {
                this.downloadURL = value;
            }
        }

        public string HashCode
        {
            get
            {
                return this.hashCode;
            }
            set
            {
                this.hashCode = value;
            }
        }

        public long Size
        {
            get
            {
                return this.size;
            }
            set
            {
                this.size = value;
            }
        }

        public string TargetVersion
        {
            get
            {
                return this.targetVersion;
            }
            set
            {
                this.targetVersion = value;
            }
        }

        public UpdateType Type
        {
            get
            {
                return this.type;
            }
            set
            {
                this.type = value;
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -