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

📄 systemfixedcontactgroupcollection.cs

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

    public class SystemFixedContactGroupCollection : ICollection<SystemFixedContactGroup>, IEnumerable<SystemFixedContactGroup>, IEnumerable
    {
        private List<SystemFixedContactGroup> _col = new List<SystemFixedContactGroup>();
        private IComparer<SystemFixedContactGroup> _comparer;
        private bool _sorted;

        public event EventHandler<InfoChangedEventArgs> InfoChanged;

        internal SystemFixedContactGroupCollection()
        {
        }

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

        public void Clear()
        {
            if (this._col.Count != 0)
            {
                this._col.Clear();
            }
        }

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

        public SystemFixedContactGroup FindContactGroup(int? groupId)
        {
            if (groupId.HasValue)
            {
                foreach (SystemFixedContactGroup group in this._col)
                {
                    if (group.Id == groupId)
                    {
                        return group;
                    }
                }
            }
            return null;
        }

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

        private void InnerDoSort()
        {
            if (this._sorted && (this._comparer != null))
            {
                this._col.Sort(this._comparer);
            }
        }

        public void InnerGroupInfoChanged(object sender, EventArgs e)
        {
            InfoChangedEventArgs args = new InfoChangedEventArgs((SystemFixedContactGroup) sender);
            if (this.InfoChanged != null)
            {
                this.InfoChanged(sender, args);
            }
        }

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

        void ICollection<SystemFixedContactGroup>.CopyTo(SystemFixedContactGroup[] array, int arrayIndex)
        {
            throw new NotSupportedException();
        }

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

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

        public SystemFixedContactGroup this[int? groupId]
        {
            get
            {
                if (!groupId.HasValue)
                {
                    return null;
                }
                return this.FindContactGroup(groupId);
            }
        }

        public IComparer<SystemFixedContactGroup> SortComparer
        {
            get
            {
                return this._comparer;
            }
            set
            {
                this._comparer = value;
                this.InnerDoSort();
            }
        }

        public bool Sorted
        {
            get
            {
                return this._sorted;
            }
            set
            {
                if (this._sorted != value)
                {
                    this._sorted = value;
                    if (this._sorted && (this._comparer == null))
                    {
                        this._comparer = new Comparer();
                    }
                    this.InnerDoSort();
                }
            }
        }

        bool ICollection<SystemFixedContactGroup>.IsReadOnly
        {
            get
            {
                return this._col.IsReadOnly;
            }
        }

        private class Comparer : IComparer<SystemFixedContactGroup>
        {
            public int Compare(SystemFixedContactGroup x, SystemFixedContactGroup y)
            {
                if (x == null)
                {
                    if (y != null)
                    {
                        return -1;
                    }
                    return 0;
                }
                if (y == null)
                {
                    return 1;
                }
                return x.SortIndex.CompareTo(y.SortIndex);
            }
        }
    }
}

⌨️ 快捷键说明

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