private ISortedDictionaryOnDisk getContainer(string storePath, out string storeName, bool createStoreIfNotExist = true, Profile config = null) { if (string.IsNullOrWhiteSpace(storePath)) { throw new ArgumentNullException("storePath"); } storeName = null; string[] parts = storePath.Split(new char[] { storeUriSeparator }, StringSplitOptions.RemoveEmptyEntries); if (parts == null || parts.Length == 0) { return(null); } var f = _server.GetFile(parts[0]); if (f == null) { // if storePath is a Store name (no File in path), simply return the SystemFile's default Store... if (parts.Length == 1) { storeName = parts[0]; return(_server.SystemFile.Store); } else if (!createStoreIfNotExist) { return(null); } else { // auto create the File if createStoreIfNotExist is true... f = _server.FileSet.Add(parts[0], profile: config); } } ISortedDictionaryOnDisk container = f.Store; for (int i = 1; i < parts.Length - 1; i++) { if (container.Contains(parts[i])) { container = (ISortedDictionaryOnDisk)container.GetValue(parts[i], null); if (container == null) { throw new SopException(string.Format("Can't recreate Store {0}", parts[i])); } continue; } if (!createStoreIfNotExist) { return(null); } container = CreateCollection(container, parts[i]); } storeName = parts[parts.Length - 1]; return(container); }
/// <summary> /// Retrieves the raw (unwrapped), object Typed Key/Value Store as referenced by storePath. /// </summary> /// <param name="storePath"></param> /// <returns>ISortedDictionaryOnDisk object</returns> public ISortedDictionaryOnDisk GetUnwrappedStore(string storePath) { string s; ISortedDictionaryOnDisk container = getContainer(storePath, out s, false); // if storePath references the File object, 'just return container as it should be the File's default Store. if (s == storePath) { return(container); } if (container == null || !container.Contains(s)) { return(null); } var v = container.GetValue(s, null); var sf = new Sop.StoreFactory(); container = sf.GetContainer(v); if (container == null) { throw new SopException(string.Format("Can't recreate Store {0}", s)); } return(container); }