예제 #1
0
        /// <summary>
        /// Setup and return the Virtual Cache
        /// </summary>
        /// <param name="ObjectCacheID"></param>
        /// <returns></returns>
        public ISortedDictionary <int, Person> GetObjectCache(int ObjectCacheID)
        {
            string CacheFilename  = "OFile" + ObjectCacheID.ToString();
            string ServerPath     = "SopBin\\";
            string ServerFilename = "OServer.dta";

            Sop.IFile f  = null;
            string    fn = string.Format("{0}{1}.{2}", ServerPath, CacheFilename, ObjectServer.DefaultFileExtension);

            if (server == null)
            {
                server = Sop.ObjectServer.OpenWithTransaction(string.Format("{0}{1}", ServerPath, ServerFilename),
                                                              new Preferences {
                    MemoryExtenderMode = true
                });
            }

            f = server.FileSet[CacheFilename];
            if (f == null)
            {
                f = server.FileSet.Add(CacheFilename, fn);
            }
            IStoreFactory sf = new StoreFactory();

            return(sf.Get <int, Person>(f.Store, "VirtualCache"));
        }
예제 #2
0
 /// <summary>
 /// StoreNavigator Constructor expecting Object Server argument.
 /// </summary>
 /// <param name="server"></param>
 public StoreNavigator(Sop.IObjectServer server)
 {
     if (server == null)
     {
         throw new ArgumentNullException("server");
     }
     _server = server;
 }
예제 #3
0
 /// <summary>
 /// Dispose will commit the transaction if it isn't commited yet.
 /// </summary>
 public void Dispose()
 {
     if (_server != null)
     {
         if (_server.SystemFile.Store.Transaction != null)
         {
             //server.SystemFile.ObjectStore.Transaction.Commit();
             _server.Transaction.Commit();
         }
         _server.Dispose();
         _server = null;
     }
 }