protected Element(VaultBase vault, String name, IEnumerable<Element> children) { Vault = vault.AssertNotNull(); Bind(Vault); // setting parent auto-adds the child to this collection // so it should be initialized as an empty one _children = new IndexedNodeCollection(this); (children ?? Enumerable.Empty<Element>()).ForEach(c => c.Parent = (Branch)this); Name = name; _metadata = new Metadata(this); }
public static IEnumerable <FsVaultEntry> BuildVaultEntries(this VaultBase vault, String uri) { var rootMetaFso = uri.FilePathCombine("$").AsFileSystemInfo(); if (rootMetaFso != null && rootMetaFso.Exists) { yield return(new FsVaultEntry(uri, rootMetaFso)); } foreach (var b in vault.Root.GetBranchesRecursive()) { var dirname = uri.DirPathCombine(b.VPath); var fso = dirname.MapPathToCoexisting(); if (fso == null || !fso.Exists) { throw new ArgumentException(String.Format( "There's no FS Object (even at a coexisting path) that corresponds to a branch '{0}'", b)); } var metaFso = fso.FullName.Slash().FilePathCombine("$").AsFileSystemInfo(); if (metaFso != null && metaFso.Exists) { yield return(new FsVaultEntry(uri, metaFso)); } yield return(new FsVaultEntry(uri, fso)); } foreach (var v in vault.Root.GetValuesRecursive(ValueKind.RegularAndInternal)) { var fileName = uri.FilePathCombine(v.VPath); var fso = fileName.MapPathToCoexisting(); if (fso == null || !fso.Exists) { throw new ArgumentException(String.Format( "There's no FS Object (even at a coexisting path) that corresponds to a value '{0}'", v)); } var fileUnbuxt = fso.FullName.Unslash().Reverse().SkipWhile(c => c == '$').Reverse().StringJoin(String.Empty); var metaFso = (fileUnbuxt + "$").AsFileSystemInfo(); if (metaFso != null && metaFso.Exists) { yield return(new FsVaultEntry(uri, metaFso)); } yield return(new FsVaultEntry(uri, fso)); } }
public Value(VaultBase vault, String name, Func<Stream> content) : base(vault, name, null) { _content = content ?? (() => null); }
public void Bind(VaultBase vault) { using (Vault.ExposeReadWrite()) { VerifyMutation(VPath); if (BoundVault == vault) return; if (BoundVault != null) Unbind(); BoundVault = vault; vault.Bind(this); } }
public Branch(VaultBase vault, String name, IEnumerable<Element> children) : base(vault, name, children) { }