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

📄 schedulesmscollection.cs

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

    public class ScheduleSmsCollection : ICollection<ScheduleSms>, IEnumerable<ScheduleSms>, IEnumerable
    {
        private List<ScheduleSms> _col = new List<ScheduleSms>();
        private IComparer<ScheduleSms> _comparer;
        private bool _sorted;
        private object _syncObj = new object();

        public void Add(ScheduleSms item)
        {
            lock (this.SyncRoot)
            {
                if (!this._col.Contains(item))
                {
                    this._col.Add(item);
                }
                this.InnerDoSort();
            }
        }

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

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

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

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

        internal void InnerDoSort()
        {
            if (this._sorted)
            {
                if (this.SortComparer != null)
                {
                    this._col.Sort(this.SortComparer);
                }
                else
                {
                    this._col.Sort();
                }
            }
        }

        public bool Remove(ScheduleSms item)
        {
            lock (this.SyncRoot)
            {
                if (this._col.Contains(item))
                {
                    return this._col.Remove(item);
                }
                return false;
            }
        }

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

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

        public bool IsReadOnly
        {
            get
            {
                return this._col.get_IsReadOnly();
            }
        }

        public ScheduleSms this[int index]
        {
            get
            {
                return this._col.get_Item(index);
            }
        }

        public ScheduleSms this[string id]
        {
            get
            {
                List<ScheduleSms>.Enumerator enumerator = this._col.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        ScheduleSms sms = enumerator.get_Current();
                        if (sms.Id == id)
                        {
                            return sms;
                        }
                    }
                }
                finally
                {
                    enumerator.Dispose();
                }
                return null;
            }
        }

        public IComparer<ScheduleSms> 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 ScheduleSmsComparer();
                    }
                    this.InnerDoSort();
                }
            }
        }

        public object SyncRoot
        {
            get
            {
                return this._syncObj;
            }
        }

        private class ScheduleSmsComparer : IComparer<ScheduleSms>
        {
            public int Compare(ScheduleSms x, ScheduleSms y)
            {
                if (x == null)
                {
                    if (y != null)
                    {
                        return -1;
                    }
                    return 0;
                }
                if (y == null)
                {
                    return 1;
                }
                int num = DateTime.Compare(x.SendTime, y.SendTime);
                if (num != 0)
                {
                    return num;
                }
                return string.Compare(x.Message, y.Message);
            }
        }
    }
}

⌨️ 快捷键说明

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