예제 #1
0
        protected virtual IList <IItemMetadata> FilterDescendantsAndSelf(IItemData root, Func <IItemMetadata, bool> predicate)
        {
            Assert.ArgumentNotNull(root, nameof(root));

            var descendants = new List <IItemMetadata>();

            var childQueue = new Queue <IItemMetadata>();

            childQueue.Enqueue(root);
            while (childQueue.Count > 0)
            {
                IItemMetadata parent = childQueue.Dequeue();

                if (predicate(parent))
                {
                    descendants.Add(parent);
                }

                SerializationBlobStorageTree tree = this.GetTreeForPath(parent.Path, root.DatabaseName);

                if (tree == null)
                {
                    continue;
                }

                IItemMetadata[] children = tree.GetChildrenMetadata(parent).ToArray();

                foreach (IItemMetadata item in children)
                {
                    childQueue.Enqueue(item);
                }
            }

            return(descendants);
        }
예제 #2
0
        protected virtual SerializationBlobStorageTree GetTreeForPath(string path, string database)
        {
            SerializationBlobStorageTree foundStorageTree = null;

            foreach (SerializationBlobStorageTree tree in this.Trees)
            {
                if (!tree.DatabaseName.Equals(database, StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                if (!tree.ContainsPath(path))
                {
                    continue;
                }

                if (foundStorageTree != null)
                {
                    throw new InvalidOperationException(
                              $"The trees {foundStorageTree.Name} and {tree.Name} both contained the global path {path}" +
                              $" - overlapping trees are not allowed.");
                }

                foundStorageTree = tree;
            }

            return(foundStorageTree);
        }
예제 #3
0
        public virtual IEnumerable <IItemData> GetByPath(string path, string database)
        {
            SerializationBlobStorageTree tree = this.GetTreeForPath(path, database);

            if (tree == null)
            {
                return(Enumerable.Empty <IItemData>());
            }

            return(tree.GetItemsByPath(path));
        }
예제 #4
0
        public virtual IEnumerable <IItemData> GetChildren(IItemData parentItem)
        {
            SerializationBlobStorageTree tree = this.GetTreeForPath(parentItem.Path, parentItem.DatabaseName);

            if (tree == null)
            {
                throw new InvalidOperationException("No trees contained the global path " + parentItem.Path);
            }

            return(tree.GetChildren(parentItem));
        }
예제 #5
0
        // note: we pass in these params (formatter, datacache) so that overriding classes may get access to private vars indirectly (can't get at them otherwise because this is called from the constructor)
        protected virtual SerializationBlobStorageTree CreateTree(TreeRoot root, ISerializationFormatter formatter, bool useDataCache, bool useBlobListCache, bool useBigFilesLazyLoad)
        {
            var tree = new SerializationBlobStorageTree(
                root.Name,
                root.Path,
                root.DatabaseName,
                Path.Combine(this.CloudRootPath, root.Name),
                formatter,
                this._connectionString,
                this._containerName,
                useDataCache,
                useBlobListCache,
                useBigFilesLazyLoad);

            return(tree);
        }