本文整理汇总了C#中ImmutableList.RunAll方法的典型用法代码示例。如果您正苦于以下问题:C# ImmutableList.RunAll方法的具体用法?C# ImmutableList.RunAll怎么用?C# ImmutableList.RunAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImmutableList
的用法示例。
在下文中一共展示了ImmutableList.RunAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Prebuild
public override IEnumerable<FileModel> Prebuild(ImmutableList<FileModel> models, IHostService host)
{
host.LogInfo("Merging platform...");
var processedUid = new HashSet<string>();
var merged = models.RunAll(m =>
{
if (m.Type != DocumentType.Article)
{
return m;
}
if (m.Uids.Length == 0)
{
host.LogWarning("Unknown model without uid.", file: m.File);
return m;
}
var mainUid = m.Uids[0];
if (processedUid.Contains(mainUid))
{
return null;
}
var sameTopics = host.LookupByUid(mainUid);
if (sameTopics.Count == 1)
{
return m;
}
processedUid.Add(mainUid);
var vm = (PageViewModel)m.Content;
m.Content = MergeCore(
mainUid,
m,
from topic in sameTopics
where topic != m
where topic.Type == DocumentType.Article
select topic,
host);
return m;
});
host.LogInfo("Platform merged.");
return from p in merged
where p != null
select p;
}
示例2: Prebuild
public override IEnumerable<FileModel> Prebuild(ImmutableList<FileModel> models, IHostService host)
{
host.LogInfo("Applying platform-version from metadata...");
models.RunAll(m =>
{
if (m.Type != DocumentType.Article)
{
return;
}
var page = m.Content as PageViewModel;
object value;
if (page?.Metadata != null &&
page.Metadata.TryGetValue("platform", out value))
{
page.Metadata.Remove("platform");
var list = GetPlatformVersionFromMetadata(value);
if (list != null)
{
list.Sort();
foreach (var item in page.Items)
{
if (item.Platform == null)
{
item.Platform = list;
}
else
{
var set = new SortedSet<string>(item.Platform);
foreach (var pv in list)
{
set.Add(pv);
}
item.Platform = set.ToList();
}
}
}
}
});
host.LogInfo("Platform applied.");
return models;
}