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

📄 systemmessage.cs

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

    public class SystemMessage : IMessage
    {
        private string _content;
        private string _extend;
        private string _id;
        private string _link;
        private MessageStatus _readok;
        private PlayerCollection _receivers;
        private DateTime _time;

        public SystemMessage()
        {
            this._receivers = new PlayerCollection();
        }

        public SystemMessage(IMessage msg)
        {
            this._receivers = new PlayerCollection();
            if (msg.Type != MessageType.System)
            {
                throw new Exception("Error, The Message is not a SystemMessage");
            }
            IMessage message = this;
            message.Body = msg.Body;
            message.ID = msg.ID;
            message.Time = msg.Time;
            if (msg.Receivers.get_Count() > 0)
            {
                message.Receivers.Add(msg.Receivers.get_Item(0));
            }
        }

        public SystemMessage(string id, string content, string link, string exprieTime)
        {
            this._receivers = new PlayerCollection();
            this._id = id;
            this._content = content;
            try
            {
                this._time = DateTime.Parse(exprieTime);
            }
            catch
            {
            }
            this._link = link;
        }

        public string Content
        {
            get
            {
                return this._content;
            }
            set
            {
                this._content = value;
            }
        }

        public Player CurrentPlayer
        {
            get
            {
                if (this._receivers.get_Count() > 0)
                {
                    return this._receivers.get_Item(0);
                }
                return null;
            }
            set
            {
                this._receivers.Clear();
                this._receivers.Add(value);
                if (this._readok != MessageStatus.Unknow)
                {
                    this.CurrentPlayer.Status = this._readok;
                }
            }
        }

        public User CurrentUser
        {
            set
            {
                Player player = new Player(value.Uri.Raw, value.Nickname, PlayerType.User);
                this.CurrentPlayer = player;
            }
        }

        public string Extend
        {
            get
            {
                return this._extend;
            }
            set
            {
                this._extend = value;
            }
        }

        public string ID
        {
            get
            {
                return this._id;
            }
            set
            {
                this._id = value;
            }
        }

        string IMessage.Body
        {
            get
            {
                XmlDocument document = new XmlDocument();
                XmlDeclaration newChild = document.CreateXmlDeclaration("1.0", "utf-8", null);
                XmlElement element = document.CreateElement("msg");
                document.InsertBefore(newChild, document.DocumentElement);
                element.SetAttribute("id", this._id);
                document.AppendChild(element);
                XmlElement element2 = document.CreateElement("content");
                element2.AppendChild(document.CreateTextNode(this._content));
                element.AppendChild(element2);
                XmlElement element3 = document.CreateElement("link");
                element3.AppendChild(document.CreateTextNode(this._link));
                element.AppendChild(element3);
                return document.InnerXml;
            }
            set
            {
                try
                {
                    XmlDocument document = new XmlDocument();
                    document.LoadXml(value);
                    this._id = XmlHelper.ReadXmlAttributeString(document.DocumentElement, "id");
                    foreach (XmlElement element in document.DocumentElement.ChildNodes)
                    {
                        if (element.Name == "content")
                        {
                            this._content = element.InnerText;
                            continue;
                        }
                        if (element.Name == "link")
                        {
                            this._link = element.InnerText;
                        }
                    }
                }
                catch
                {
                    this._content = value;
                    this._link = string.Empty;
                    this._id = "0";
                }
            }
        }

        string IMessage.ID
        {
            get
            {
                return ("SystemMessage:" + this._id);
            }
            set
            {
                this._id = value.Substring(13);
            }
        }

        PlayerCollection IMessage.Receivers
        {
            get
            {
                return this._receivers;
            }
        }

        Player IMessage.Sender
        {
            get
            {
                return Player.SYSTEM;
            }
            set
            {
            }
        }

        MessageType IMessage.Type
        {
            get
            {
                return MessageType.System;
            }
            set
            {
            }
        }

        public string Link
        {
            get
            {
                return this._link;
            }
            set
            {
                this._link = value;
            }
        }

        public bool Readok
        {
            get
            {
                if (this.CurrentPlayer != null)
                {
                    return (this.CurrentPlayer.Status == MessageStatus.Successed);
                }
                return (this._readok == MessageStatus.Successed);
            }
            set
            {
                if (this.CurrentPlayer != null)
                {
                    if (value)
                    {
                        this.CurrentPlayer.Status = MessageStatus.Successed;
                    }
                    else
                    {
                        this.CurrentPlayer.Status = MessageStatus.Failed;
                    }
                }
                else if (value)
                {
                    this._readok = MessageStatus.Successed;
                }
                else
                {
                    this._readok = MessageStatus.Failed;
                }
            }
        }

        public DateTime Time
        {
            get
            {
                return this._time;
            }
            set
            {
                this._time = value;
            }
        }
    }
}

⌨️ 快捷键说明

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