public static StorageRoot CreateStorage(string path, bool createIfNotExists, StorageOptions storageOptions = null) { var provider = new FileStorgeProvider(path, createIfNotExists); var ret = new StorageRoot(provider, storageOptions); return(ret); }
public static StorageRoot CreateStorage(Stream stream, Uri streamUri = null, string streamName = null, StorageOptions storageOptions = null) { var provider = new ZipStorgeProvider(stream, streamUri, streamName); var ret = new StorageRoot(provider, storageOptions); return(ret); }
public static StorageRoot CreateStorage(string zipPath, StorageOptions storageOptions = null) { var provider = new ZipStorgeProvider(zipPath); var ret = new StorageRoot(provider, storageOptions); return(ret); }
StorageBasedPackageProperties( StorageRoot root ) { _pss = (IPropertySetStorage)root.GetRootIStorage(); // // Open the property sets with the same access with which the file itself // was opened. // _grfMode = SafeNativeCompoundFileConstants.STGM_DIRECT | SafeNativeCompoundFileConstants.STGM_SHARE_EXCLUSIVE; SafeNativeCompoundFileMethods.UpdateModeFlagFromFileAccess(root.OpenAccess, ref _grfMode); OpenPropertyStorage(ref FormatId.SummaryInformation, out _psSummInfo); OpenPropertyStorage(ref FormatId.DocumentSummaryInformation, out _psDocSummInfo); }
public static void Main(string[] args) { Storage db = StorageFactory.Instance.CreateStorage(); for (int i = 0; i < args.Length; i++) { if ("background".Equals(args[i])) { db.SetProperty("perst.background.gc", true); } else if ("altbtree".Equals(args[i])) { db.SetProperty("perst.alternative.btree", true); } else { Console.Error.WriteLine("Unrecognized option: " + args[i]); } } db.Open("testgc.dbs"); db.GcThreshold = 1000000; StorageRoot root = new StorageRoot(); root.strIndex = db.CreateIndex(typeof(string), true); root.intIndex = db.CreateIndex(typeof(long), true); db.SetRoot(root); Index intIndex = root.intIndex; Index strIndex = root.strIndex; long insKey = 1999; long remKey = 1999; int i2; for (i2 = 0; i2 < nIterations; i2++) { if (i2 > nObjectsInTree) { remKey = (3141592621L * remKey + 2718281829L) % 1000000007L; intIndex.Remove(new Key(remKey)); strIndex.Remove(new Key(Convert.ToString(remKey))); } PObject obj = new PObject(); insKey = (3141592621L * insKey + 2718281829L) % 1000000007L; obj.intKey = insKey; obj.strKey = Convert.ToString(insKey); obj.next = new PObject(); intIndex.Put(new Key(obj.intKey), obj); strIndex.Put(new Key(obj.strKey), obj); if (i2 > 0) { Assert.That(root.list.intKey == i2 - 1); } root.list = new PObject(); root.list.intKey = i2; root.Store(); if (i2 % 1000 == 0) { Console.Out.Write("Iteration " + i2 + "\r"); Console.Out.Flush(); db.Commit(); } } db.Close(); }
static public void Main(String[] args) { Storage db = StorageFactory.Instance.CreateStorage(); for (int i = 0; i < args.Length; i++) { if ("altbtree" == args[i]) { db.SetProperty("perst.alternative.btree", true); } else if ("background" == args[i]) { db.SetProperty("perst.background.gc", true); } else { Console.WriteLine("Unrecognized option: " + args[i]); } } db.Open("testgc.dbs"); db.SetGcThreshold(1000000); StorageRoot root = new StorageRoot(); root.strIndex = db.CreateIndex(typeof(String), true); root.intIndex = db.CreateIndex(typeof(long), true); db.Root = root; Index intIndex = root.intIndex; Index strIndex = root.strIndex; long insKey = 1999; long remKey = 1999; for (int i = 0; i < nIterations; i++) { if (i > nObjectsInTree) { remKey = (3141592621L * remKey + 2718281829L) % 1000000007L; intIndex.Remove(new Key(remKey)); strIndex.Remove(new Key(remKey.ToString())); } PObject obj = new PObject(); insKey = (3141592621L * insKey + 2718281829L) % 1000000007L; obj.intKey = insKey; obj.strKey = insKey.ToString(); obj.next = new PObject(); intIndex.Put(new Key(obj.intKey), obj); strIndex.Put(new Key(obj.strKey), obj); if (i > 0) { Debug.Assert(root.list.intKey == i - 1); } root.list = new PObject(); root.list.intKey = i; root.Store(); if (i % 1000 == 0) { db.Commit(); Console.Write("Iteration " + i + "\r"); } } db.Close(); }