Esempio n. 1
0
 public override List <T> FindAll()
 {
     if (CachingPolicy == CachingPolicy.Dictionary)
     {
         RefreshCacheIfNeed();
     }
     if ((CachingPolicy != CachingPolicy.None) && (IsWholeCacheValid))
     {
         return(_cache.GetAll());
     }
     return(ReNewCacheFromBase());
 }
Esempio n. 2
0
        public virtual void RestoreFromStream(Stream stream)
        {
            Debug.Assert(stream.CanRead,
                         string.Format("stream \"{0}\" doesn't support Read operation", stream.GetType().FullName));

            BinaryFormatter bf = new BinaryFormatter();

            _cache = (EntityCache <T>)(bf.Deserialize(stream));

            // suppose we should call AfterEntitiesLoaded() or overload Save/RestoreFromStream()
            // for specific local services to implement custom client serialization
            // of fields that was marked as non-serialized for better remoting performance
            AfterEntitiesLoaded(_cache.GetAll());
        }