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

📄 custompresencecollection.cs

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

    public class CustomPresenceCollection : IEnumerable<CustomPresence>, IEnumerable
    {
        private List<CustomPresence> _customerPresences = new List<CustomPresence>();
        private bool _modified = false;
        private const string strNodeName = "CustomerPresence";

        internal CustomPresenceCollection()
        {
        }

        public void Clear()
        {
            this._customerPresences.Clear();
            this._modified = true;
        }

        public bool Countains(string desc)
        {
            return (this.IndexOf(desc) >= 0);
        }

        public IEnumerator<CustomPresence> GetEnumerator()
        {
            return this._customerPresences.GetEnumerator();
        }

        public int IndexOf(string desc)
        {
            for (int i = 0; i < this._customerPresences.get_Count(); i++)
            {
                if (this._customerPresences.get_Item(i).Desccription == desc)
                {
                    return i;
                }
            }
            return -1;
        }

        public void LoadXml(XmlNode xmlNode)
        {
            this.Clear();
            foreach (XmlNode node in xmlNode.ChildNodes)
            {
                try
                {
                    MainPresence basicPresence = (MainPresence) Enum.Parse(typeof(MainPresence), node.Name.Substring("CustomerPresence".Length));
                    this.TryAdd(node.InnerText, basicPresence);
                    continue;
                }
                catch
                {
                    continue;
                }
            }
            this._modified = false;
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return this._customerPresences.GetEnumerator();
        }

        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("<CustomerPresences>");
            List<CustomPresence>.Enumerator enumerator = this._customerPresences.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    CustomPresence presence = enumerator.get_Current();
                    builder.Append(string.Format("<{0}><![CDATA[{1}]]></{0}>", string.Format("CustomerPresence{0}", (int) presence.BasicPresence), presence.Desccription));
                }
            }
            finally
            {
                enumerator.Dispose();
            }
            builder.Append("</CustomerPresences>");
            return builder.ToString();
        }

        public bool TryAdd(string desc, MainPresence basicPresence)
        {
            if (this.Countains(desc))
            {
                return false;
            }
            this._customerPresences.Add(new CustomPresence(desc, basicPresence));
            this._modified = true;
            return true;
        }

        public bool TryRemove(string desc)
        {
            int index = this.IndexOf(desc);
            if (index < 0)
            {
                return false;
            }
            this._customerPresences.RemoveAt(index);
            this._modified = true;
            return true;
        }

        public bool TryUpdate(string oldDesc, string desc, MainPresence basicPresence)
        {
            int index = this.IndexOf(oldDesc);
            if (index < 0)
            {
                return false;
            }
            int num2 = this.IndexOf(desc);
            if ((num2 >= 0) && (index != num2))
            {
                return false;
            }
            this._customerPresences.get_Item(index).Desccription = desc;
            this._customerPresences.get_Item(index).BasicPresence = basicPresence;
            this._modified = true;
            return true;
        }

        public int Count
        {
            get
            {
                return this._customerPresences.get_Count();
            }
        }

        public CustomPresence this[int index]
        {
            get
            {
                return this._customerPresences.get_Item(index);
            }
        }

        public MainPresence this[string desc]
        {
            get
            {
                int index = this.IndexOf(desc);
                if (index < 0)
                {
                    return MainPresence.Unknown;
                }
                return this._customerPresences.get_Item(index).BasicPresence;
            }
        }

        public bool Modified
        {
            get
            {
                return this._modified;
            }
            set
            {
                this._modified = value;
            }
        }
    }
}

⌨️ 快捷键说明

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