本文整理汇总了C#中ISelectable.SelectList方法的典型用法代码示例。如果您正苦于以下问题:C# ISelectable.SelectList方法的具体用法?C# ISelectable.SelectList怎么用?C# ISelectable.SelectList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISelectable
的用法示例。
在下文中一共展示了ISelectable.SelectList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExtractField
private dynamic ExtractField(ISelectable item, Page page, DataToken field, int index)
{
ISelector selector = SelectorUtil.Parse(field.Selector);
if (selector == null)
{
return null;
}
var f = field as Field;
List<Formatter.Formatter> formatters = GenerateFormatter(f?.Formatters);
bool isEntity = field is Entity;
if (!isEntity)
{
string tmpValue;
if (selector is EnviromentSelector)
{
var enviromentSelector = selector as EnviromentSelector;
tmpValue = GetEnviromentValue(enviromentSelector.Field, page, index);
foreach (var formatter in formatters)
{
tmpValue = formatter.Formate(tmpValue);
}
return tmpValue;
}
else
{
bool needPlainText = (((Field)field).Option == PropertyExtractBy.ValueOption.PlainText);
if (field.Multi)
{
var propertyValues = item.SelectList(selector).Nodes();
List<string> results = new List<string>();
foreach (var propertyValue in propertyValues)
{
string tmp = propertyValue.GetValue(needPlainText);
foreach (var formatter in formatters)
{
tmp = formatter.Formate(tmp);
}
results.Add(tmp);
}
return new JArray(results);
}
else
{
bool needCount = (((Field)field).Option == PropertyExtractBy.ValueOption.Count);
if (needCount)
{
var propertyValues = item.SelectList(selector).Nodes();
return propertyValues != null ? propertyValues.Count.ToString() : "-1";
}
else
{
tmpValue = item.Select(selector)?.GetValue(needPlainText);
tmpValue = formatters.Aggregate(tmpValue, (current, formatter) => formatter.Formate(current));
return tmpValue;
}
}
}
}
else
{
if (field.Multi)
{
var propertyValues = item.SelectList(selector).Nodes();
JArray objs = new JArray();
var selectables = item.SelectList(selector).Nodes();
foreach (var selectable in selectables)
{
JObject obj = new JObject();
foreach (var child in ((Entity)field).Fields)
{
obj.Add(child.Name, ExtractField(selectable, page, child, 0));
}
objs.Add(obj);
}
return objs;
}
else
{
JObject obj = new JObject();
var selectable = item.Select(selector);
foreach (var child in ((Entity)field).Fields)
{
obj.Add(child.Name, ExtractField(selectable, page, field, 0));
}
return obj;
}
}
}