Пример #1
0
        public virtual int Count(Func <T, bool> filter)
        {
            LogStopwatch watch = new LogStopwatch(this.GetTypeName() + ".Count", "CacheList: " + this.CacheList.Count);

            watch.Start();

            try
            {
                return(this.CacheList.Count(filter));
            }
            finally
            {
                watch.Stop();
            }
        }
Пример #2
0
        public List <T> Filtrate(CacheFilter <T> filter, out int totalCount)
        {
            LogStopwatch watch = new LogStopwatch(this.GetType().Name + ".Filtrate", "");

            watch.Start();

            try
            {
                return(filter.Filtrate(this.CacheList, out totalCount));
            }
            finally
            {
                watch.Stop();
            }
        }
Пример #3
0
        public bool Any(Func <T, bool> filter)
        {
            LogStopwatch watch = new LogStopwatch(this.GetType().Name + ".Any", "");

            watch.Start();

            this.Lock.AcquireReaderLock(10000);
            try
            {
                return(this._cacheList.Any(filter));
            }
            finally
            {
                this.Lock.ReleaseReaderLock();
                watch.Stop();
            }
        }
Пример #4
0
        public void ForEach(Action <T> action)
        {
            LogStopwatch watch = new LogStopwatch(this.GetTypeName() + ".ForEach", "CacheList: " + this.CacheList.Count);

            watch.Start();

            try
            {
                foreach (T t in this.CacheList)
                {
                    action(t);
                }
            }
            finally
            {
                watch.Stop();
            }
        }
Пример #5
0
        public virtual List <object> Take(int count)
        {
            this.EnableValidate();

            LogStopwatch watch = new LogStopwatch(this.GetType().Name + ".Take", "");

            watch.Start();

            this.Lock.AcquireReaderLock(10000);
            try
            {
                return(this._cacheList.Take(count).Select(cache => cache as object).ToList());
            }
            finally
            {
                this.Lock.ReleaseReaderLock();
                watch.Stop();
            }
        }
Пример #6
0
        public bool Contains(T cache)
        {
            this.EnableValidate();

            LogStopwatch watch = new LogStopwatch(this.GetType().Name + ".Contains", "");

            watch.Start();

            this.Lock.AcquireReaderLock(10000);
            try
            {
                return(this._cacheList.Contains(cache));
            }
            finally
            {
                this.Lock.ReleaseReaderLock();
                watch.Stop();
            }
        }
Пример #7
0
        public virtual int Count(Func <T, bool> filter)
        {
            this.EnableValidate();

            LogStopwatch watch = new LogStopwatch(this.GetType().Name + ".Count", "");

            watch.Start();

            this.Lock.AcquireReaderLock(10000);
            try
            {
                return(this._cacheList.Count(filter));
            }
            finally
            {
                this.Lock.ReleaseReaderLock();
                watch.Stop();
            }
        }
Пример #8
0
        public List <T> Filtrate(CacheFilter <T> filter)
        {
            this.EnableValidate();

            LogStopwatch watch = new LogStopwatch(this.GetType().Name + ".Filtrate", "");

            watch.Start();

            this.Lock.AcquireReaderLock(10000);
            try
            {
                return(filter.Filtrate(this._cacheList));
            }
            finally
            {
                this.Lock.ReleaseReaderLock();
                watch.Stop();
            }
        }
Пример #9
0
        public void ForEach(Action <T> action)
        {
            this.EnableValidate();

            LogStopwatch watch = new LogStopwatch(this.GetType().Name + ".ForEach", "");

            watch.Start();

            this.Lock.AcquireReaderLock(10000);
            try
            {
                foreach (T t in this._cacheList)
                {
                    action(t);
                }
            }
            finally
            {
                this.Lock.ReleaseReaderLock();
                watch.Stop();
            }
        }