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

📄 treenodecontactcollection.cs

📁 飞信的收发使用csharp进行开发
💻 CS
字号:
namespace Imps.Client.Pc.UIContactList
{
    using Imps.Client.Pc.BizControls;
    using Imps.Common;
    using System;
    using System.Collections;
    using System.Collections.Generic;

    public class TreeNodeContactCollection : ICollection<TreeNodeContact>, IEnumerable<TreeNodeContact>, IEnumerable
    {
        private List<TreeNodeContact> _col = new List<TreeNodeContact>();

        public void Add(TreeNodeContact item)
        {
            this._col.Add(item);
        }

        public void Add(NodeKey nodeKeyValue, int groupId)
        {
            TreeNodeContact item = new TreeNodeContact(nodeKeyValue, groupId);
            this._col.Add(item);
        }

        public void Add(NodeKey nodeKeyValue, string uri)
        {
            TreeNodeContact item = new TreeNodeContact(nodeKeyValue, uri);
            this._col.Add(item);
        }

        public void Clear()
        {
            this._col.Clear();
        }

        public bool Contains(TreeNodeContact item)
        {
            return this._col.Contains(item);
        }

        public void CopyTo(TreeNodeContact[] array, int arrayIndex)
        {
            throw new NotSupportedException();
        }

        public int? FindContactGroupId(NodeKey nodeKeyValue)
        {
            foreach (TreeNodeContact contact in this._col)
            {
                if (!contact.IsContactNode && (contact.NodeKeyValue == nodeKeyValue))
                {
                    return new int?(contact.ContactGroupId);
                }
            }
            return null;
        }

        public NodeKey FindContactGroupNodeKey(int contactGroupId)
        {
            foreach (TreeNodeContact contact in this._col)
            {
                if (!contact.IsContactNode && (contact.ContactGroupId == contactGroupId))
                {
                    return contact.NodeKeyValue;
                }
            }
            return null;
        }

        public NodeKeyCollection FindContactNodeKey(string uri)
        {
            if (!new IicUri(uri).IsValid)
            {
                return null;
            }
            NodeKeyCollection keys = new NodeKeyCollection();
            foreach (TreeNodeContact contact in this._col)
            {
                if (contact.IsContactNode && (contact.ContactUri == uri))
                {
                    keys.Add(contact.NodeKeyValue);
                }
            }
            return keys;
        }

        public string FindContactUri(NodeKey nodeKeyValue)
        {
            foreach (TreeNodeContact contact in this._col)
            {
                if (contact.IsContactNode && (contact.NodeKeyValue == nodeKeyValue))
                {
                    return contact.ContactUri;
                }
            }
            return string.Empty;
        }

        public IEnumerator<TreeNodeContact> GetEnumerator()
        {
            return this._col.GetEnumerator();
        }

        public void Remove(NodeKey nodeKey)
        {
            for (int i = this._col.Count - 1; i >= 0; i--)
            {
                if (this._col[i].IsContactNode && (this._col[i].NodeKeyValue == nodeKey))
                {
                    this._col.RemoveAt(i);
                }
            }
        }

        public bool Remove(TreeNodeContact item)
        {
            return (this.Contains(item) && this._col.Remove(item));
        }

        public void Remove(int groupId)
        {
            for (int i = this._col.Count - 1; i >= 0; i--)
            {
                if (!this._col[i].IsContactNode && (this._col[i].ContactGroupId == groupId))
                {
                    this._col.RemoveAt(i);
                }
            }
        }

        public void Remove(string contactUri)
        {
            for (int i = this._col.Count - 1; i >= 0; i--)
            {
                if (this._col[i].IsContactNode && (this._col[i].ContactUri == contactUri))
                {
                    this._col.RemoveAt(i);
                }
            }
        }

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

        public int Count
        {
            get
            {
                return this._col.Count;
            }
        }

        public bool IsReadOnly
        {
            get
            {
                return this._col.IsReadOnly;
            }
        }
    }
}

⌨️ 快捷键说明

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