コード例 #1
0
        public void Add(MessageQuery key, TItem value)
        {
            if (key == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("key");
            }

            Type queryType = key.GetType();
            MessageQueryCollection collection;

            if (!this.collectionsByType.TryGetValue(queryType, out collection))
            {
                collection = key.CreateMessageQueryCollection();

                if (collection == null)
                {
                    collection = new SequentialMessageQueryCollection();
                }

                this.collectionsByType.Add(queryType, collection);
            }

            collection.Add(key);
            this.dictionary.Add(key, value);
        }
コード例 #2
0
        public bool Remove(MessageQuery key)
        {
            if (!this.dictionary.Remove(key))
            {
                return(false);
            }
            System.Type            type   = key.GetType();
            MessageQueryCollection querys = this.collectionsByType[type];

            querys.Remove(key);
            if (querys.Count == 0)
            {
                this.collectionsByType.Remove(type);
            }
            return(true);
        }
コード例 #3
0
        public void Add(MessageQuery key, TItem value)
        {
            MessageQueryCollection querys;

            if (key == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("key");
            }
            System.Type type = key.GetType();
            if (!this.collectionsByType.TryGetValue(type, out querys))
            {
                querys = key.CreateMessageQueryCollection();
                if (querys == null)
                {
                    querys = new SequentialMessageQueryCollection <TItem>();
                }
                this.collectionsByType.Add(type, querys);
            }
            querys.Add(key);
            this.dictionary.Add(key, value);
        }
コード例 #4
0
        public bool Remove(MessageQuery key)
        {
            if (this.dictionary.Remove(key))
            {
                MessageQueryCollection collection;
                Type queryType = key.GetType();

                collection = this.collectionsByType[queryType];
                collection.Remove(key);

                if (collection.Count == 0)
                {
                    this.collectionsByType.Remove(queryType);
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }