Beispiel #1
0
        protected virtual SerializationFileSystemTree GetTreeForPath(string path, string database)
        {
            SerializationFileSystemTree foundTree = null;

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

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

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

                foundTree = tree;
            }

            return(foundTree);
        }
Beispiel #2
0
        public static void CreateTestTree(this SerializationFileSystemTree tree, string globalPath, string database = "master")
        {
            var localPath = tree.ConvertGlobalVirtualPathToTreeVirtualPath(globalPath)
                            .TrimStart('/')
                            .Split('/');

            var      contextPath     = string.Empty;
            Guid     currentParentId = default(Guid);
            FakeItem currentParent   = null;

            foreach (var pathPiece in localPath)
            {
                // the first path piece will equal the last segment in the global root - don't double append
                if (pathPiece != localPath[0])
                {
                    contextPath += "/" + pathPiece;
                }

                var item = AsTestItem(tree.GlobalRootItemPath + contextPath, currentParentId, databaseName: database);

                currentParentId = item.Id;

                currentParent?.SetProxyChildren(new[] { item });
                currentParent = item;

                tree.Save(item);
            }
        }
Beispiel #3
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 SerializationFileSystemTree CreateTree(TreeRoot root, ISerializationFormatter formatter,
                                                                 bool useDataCache)
        {
            var tree = new SerializationFileSystemTree(root.Name, root.Path, root.DatabaseName,
                                                       Path.Combine(PhysicalRootPath, root.Name), formatter, useDataCache);

            return(tree);
        }