当前位置: 首页>>代码示例>>C#>>正文


C# Branch.GetValuesRecursive方法代码示例

本文整理汇总了C#中Branch.GetValuesRecursive方法的典型用法代码示例。如果您正苦于以下问题:C# Branch.GetValuesRecursive方法的具体用法?C# Branch.GetValuesRecursive怎么用?C# Branch.GetValuesRecursive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Branch的用法示例。


在下文中一共展示了Branch.GetValuesRecursive方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ZipVault

        public ZipVault(String fileName) 
        {
            using (InternalExpose())
            {
                Zip = new ZipFile(fileName, Encoding.UTF8);
                var zeIndex = Zip.Entries.ToDictionary(ze => ze.FileName, ze => ze);
                Root = new Branch(this, null, null);

                foreach (var value in Zip.Entries.Where(e => !e.IsDirectory && !e.FileName.EndsWith("$")))
                {
                    var contentFile = value.FileName;
                    var metadataFile = contentFile + "$";

                    var valueNode = (Value)Root.CreateValue(value.FileName, ValueKind.RegularAndInternal);
                    valueNode.SetContent(() => zeIndex[contentFile].ExtractEager());
                    valueNode.RawSetMetadata(() => zeIndex.GetOrDefault(metadataFile).ExtractEager());
                }

                foreach (var branch in Zip.Entries.Where(e => e.IsDirectory && !e.FileName.EndsWith("$")))
                {
                    // no need for slash, because dirname includes it
                    var metadataFile = branch.FileName + "$";

                    // some of those branches will already be created by this time
                    var branchNode = (Branch)Root.GetOrCreateBranch(branch.FileName);
                    branchNode.RawSetMetadata(() => zeIndex.GetOrDefault(metadataFile).ExtractEager());
                }

                // for backward compatibility (DO NOT REMOVE again, please)
                var oldVersionStorage = Zip.Entries.SingleOrDefault(e => !e.IsDirectory && 
                    e.FileName == "version$" || e.FileName == "/version$" || e.FileName == "\\version$");
                if (oldVersionStorage != null)
                {
                    var matchingValue = Root.GetValue("version");
                    var possibleOverlap = Root.GetValue("$version");
                    if (matchingValue == null && possibleOverlap == null)
                    {
                        var versionHolder = Root.CreateValue("$version", ValueKind.Regular);
                        versionHolder.SetContent(() => zeIndex[oldVersionStorage.FileName].ExtractEager());
                    }
                }

                // root metadata requires special treatment since root doesn't get enumerated
                Root.RawSetMetadata(() => (zeIndex.GetOrDefault("/$") ?? zeIndex.GetOrDefault("$")).ExtractEager());

                Root.AfterLoad();
                Root.GetBranchesRecursive().Cast<Branch>().ForEach(b => b.AfterLoad());
                Root.GetValuesRecursive(ValueKind.RegularAndInternal).Cast<Value>().ForEach(v => v.AfterLoad());

                (Id != Guid.Empty).AssertTrue();
                (Revision is UInt64).AssertTrue();
            }
        }
开发者ID:xeno-by,项目名称:datavault,代码行数:53,代码来源:ZipVault.cs

示例2: FsVault

        public FsVault(String dirName)
        {
            using (InternalExpose())
            {
                Dir = new DirectoryInfo(dirName);
                var index = Entries.ToDictionary(e => e.RelPath, e => e);
                Root = new Branch(this, null, null);

                foreach (var value in Entries.Where(e => e.IsValue))
                {
                    var contentFile = value;

                    var cfileUnbuxt = value.RelPath.Reverse().SkipWhile(c => c == '$').Reverse().StringJoin(String.Empty);
                    var metadataFile = index.GetOrDefault(cfileUnbuxt + "$");

                    var valueNode = (Value)Root.CreateValue(value.VPath, ValueKind.RegularAndInternal);
                    valueNode.SetContent(contentFile.ExtractEager);
                    if (metadataFile != null) valueNode.RawSetMetadata(metadataFile.ExtractEager);
                }

                foreach (var branch in Entries.Where(e => e.IsBranch))
                {
                    // no need for slash since relpath already contains it
                    var metadataFile = index.GetOrDefault(branch.RelPath + "$");

                    // this permits duplicate directory entries
                    // it's ugly, but i'm cba to fix this at the moment
                    var branchNode = (Branch)Root.GetOrCreateBranch(branch.VPath);
                    if (metadataFile != null) branchNode.RawSetMetadata(metadataFile.ExtractEager);
                }

                // for backward compatibility (DO NOT REMOVE again, please)
                var oldVersionStorage = Entries.SingleOrDefault(e => e.IsValue && e.VPath == "version$");
                if (oldVersionStorage != null)
                {
                    var matchingValue = Root.GetValue("version");
                    var possibleOverlap = Root.GetValue("$version");
                    if (matchingValue == null && possibleOverlap == null)
                    {
                        var versionHolder = Root.CreateValue("$version", ValueKind.Regular);
                        versionHolder.SetContent(oldVersionStorage.ExtractEager);
                    }
                }

                Root.AfterLoad();
                Root.GetBranchesRecursive().Cast<Branch>().ForEach(b => b.AfterLoad());
                Root.GetValuesRecursive(ValueKind.RegularAndInternal).Cast<Value>().ForEach(v => v.AfterLoad());

                (Id != Guid.Empty).AssertTrue();
                (Revision is UInt64).AssertTrue();
            }
        }
开发者ID:xeno-by,项目名称:datavault,代码行数:52,代码来源:FsVault.cs


注:本文中的Branch.GetValuesRecursive方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。