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

📄 multimessagereceiver.cs

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

    public class MultiMessageReceiver
    {
        private int _allCount;
        private IList<string> _allKeys;
        private IDictionary<string, object> _contexts;
        private int _criticalCount;
        private IList<string> _criticalKeys;

        public event EventHandler AllMessagesReceived;

        public event EventHandler CriticalMessagesReceived;

        public MultiMessageReceiver(string[] allKeys)
        {
            this._criticalKeys = new List<string>();
            this._allKeys = new List<string>(allKeys);
            this._contexts = new SortedDictionary<string, object>();
            this._allCount = this._allKeys.get_Count();
            this._criticalCount = this._criticalKeys.get_Count();
        }

        public MultiMessageReceiver(string[] criticalKeys, string[] otherKeys)
        {
            this._criticalKeys = new List<string>(criticalKeys);
            this._allKeys = new List<string>(criticalKeys);
            foreach (string text in otherKeys)
            {
                this._allKeys.Add(text);
            }
            this._contexts = new SortedDictionary<string, object>();
            this._allCount = this._allKeys.get_Count();
            this._criticalCount = this._criticalKeys.get_Count();
        }

        protected void OnAllMessagesReceived(EventArgs e)
        {
            EventHandler allMessagesReceived = this.AllMessagesReceived;
            if (allMessagesReceived != null)
            {
                allMessagesReceived(this, e);
            }
        }

        protected void OnCriticalMessagesReceived(EventArgs e)
        {
            EventHandler criticalMessagesReceived = this.CriticalMessagesReceived;
            if (criticalMessagesReceived != null)
            {
                criticalMessagesReceived(this, e);
            }
        }

        public void ReceiveMessage(string key, object data)
        {
            lock (this)
            {
                this._contexts.Add(key, data);
                if (this._criticalKeys.Contains(key) && (--this._criticalCount <= 0))
                {
                    this.OnCriticalMessagesReceived(EventArgs.Empty);
                }
                if (--this._allCount <= 0)
                {
                    this.OnCriticalMessagesReceived(EventArgs.Empty);
                }
            }
        }

        public void Reset()
        {
            lock (this)
            {
                this._contexts.Clear();
                this._allCount = this._allKeys.get_Count();
                this._criticalCount = this._criticalKeys.get_Count();
            }
        }

        public object this[string key]
        {
            get
            {
                lock (this)
                {
                    return this._contexts.get_Item(key);
                }
            }
        }
    }
}

⌨️ 快捷键说明

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