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


C# Branch.RawSetMetadata方法代码示例

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


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

示例1: ToBranch

        public IBranch ToBranch(IVault vault)
        {
            // fixup xmlwriter's error
            Name = Name == null ? null : Name.Replace("\n", Environment.NewLine);
            Metadata = Metadata == null ? null : Metadata.Replace("\n", Environment.NewLine);

            var values = Values.Select(v => v.ToValue(vault)).Cast<Element>();
            var branches = Branches.Select(b => b.ToBranch(vault)).Cast<Element>();

            var branch = new Branch((VaultBase)vault, Name, values.Concat(branches));
            return branch.RawSetMetadata(Metadata);
        }
开发者ID:xeno-by,项目名称:datavault,代码行数:12,代码来源:XmlBranchDto.cs

示例2: 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


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