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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }