本文整理汇总了C#中FieldCollection.Sort方法的典型用法代码示例。如果您正苦于以下问题:C# FieldCollection.Sort方法的具体用法?C# FieldCollection.Sort怎么用?C# FieldCollection.Sort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FieldCollection
的用法示例。
在下文中一共展示了FieldCollection.Sort方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildListWithFieldsToShow
private IEnumerable<FieldDescriptor> BuildListWithFieldsToShow(string fieldString)
{
var fieldList = new List<FieldDescriptor>();
var fieldNames = new ListString(fieldString).ToArray();
if (fieldNames.Any())
{
IncludePatterns =
fieldNames
.Where(name => !name.StartsWith("-"))
.Select(
name =>
new WildcardPattern(name, WildcardOptions.IgnoreCase | WildcardOptions.CultureInvariant))
.ToList();
ExcludePatterns =
fieldNames
.Where(name => name.StartsWith("-"))
.Select(
name =>
new WildcardPattern(name.Substring(1),
WildcardOptions.IgnoreCase | WildcardOptions.CultureInvariant))
.ToList();
}
var currentItem = CurrentItem;
currentItem.Fields.ReadAll();
var template =
TemplateManager.GetTemplate(Settings.DefaultBaseTemplate,
currentItem.Database);
FieldCollection fields = new FieldCollection(CurrentItem);
fields.ReadAll();
fields.Sort();
foreach (Field field in fields)
{
//if not including standard field and it's standard, skip it.
if (!IncludeStandardFields && template.ContainsField(field.ID))
{
continue;
}
var name = field.Name;
var wildcardMatch = IncludePatterns.Any(pattern => pattern.IsMatch(name));
if (!wildcardMatch)
{
continue;
}
if (ExcludePatterns.Any(pattern => pattern.IsMatch(name)))
{
wildcardMatch = false;
}
if (wildcardMatch)
{
fieldList.Add(new FieldDescriptor(currentItem, field.Name));
}
}
return fieldList;
}