本文整理汇总了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);
}
示例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();
}
}