本文整理汇总了C#中ElementRequest.ToAccessorDef方法的典型用法代码示例。如果您正苦于以下问题:C# ElementRequest.ToAccessorDef方法的具体用法?C# ElementRequest.ToAccessorDef怎么用?C# ElementRequest.ToAccessorDef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElementRequest
的用法示例。
在下文中一共展示了ElementRequest.ToAccessorDef方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Build
public override HtmlTag Build(ElementRequest request)
{
Action<SelectTag> action = x =>
{
var value = request.RawValue is DomainEntity ? ((DomainEntity)request.RawValue).EntityId : request.RawValue;
var propertyName = request.ToAccessorDef().Accessor.FieldName;
var listPropertyInfo = request.ToAccessorDef().ModelType.GetProperty(propertyName+"List");
var selectListItems = listPropertyInfo.GetValue(request.Model, null) as IEnumerable<SelectListItem>;
if (selectListItems == null) return;
selectListItems.Each(option=> x.Option(option.Text, option.Value.IsNotEmpty() ? option.Value: ""));
if (value != null && value.ToString().IsNotEmpty())
{
x.SelectByValue(value.ToString());
}
};
return new SelectTag(action);
}
示例2: Build
public override HtmlTag Build(ElementRequest request)
{
Action<SelectTag> action = x =>
{
var value = request.RawValue;
var propertyName = request.ToAccessorDef().Accessor.FieldName;
var listPropertyInfo = request.ToAccessorDef().ModelType.GetProperty(propertyName + "List");
var dictionary = listPropertyInfo.GetValue(request.Model, null) as IDictionary<string, IEnumerable<SelectListItem>>;
if (dictionary == null) return;
x.Option(CoreLocalizationKeys.SELECT_ITEM.ToString(),"");
dictionary.Keys.Each(key =>
{
x.OptionGroup(key);
dictionary[key].Each(l => x.Option(l.Text, l.Value+"_"+key));
});
if (value != null && value.ToString().IsNotEmpty())
{
x.SelectByValue(value.ToString());
}
};
return new SelectTag(action);
}
示例3: buildTag
private HtmlTag buildTag(ElementRequest request)
{
var accessorDef = request.ToAccessorDef();
foreach (var builder in _sources)
{
var creator = builder.CreateInitial(accessorDef);
if (creator == null) continue;
var tag = creator(request);
if (tag != null) return tag;
}
throw new FubuException(3000, "Html Conventions have no tag builder for {0}.{1}", accessorDef.ModelType.FullName, accessorDef.Accessor.Name);
}
示例4: Build
public HtmlTag Build(ElementRequest request)
{
return _creators[request.ToAccessorDef()](request);
}
示例5: Build
public override HtmlTag Build(ElementRequest request)
{
var accessorDef = request.ToAccessorDef();
var literalList = accessorDef.Accessor.PropertyType.GetGenericArguments().Single();
return BuildTag(request, literalList);
}
示例6: Build
public HtmlTag Build(ElementRequest request, int index, int count)
{
return _creators[request.ToAccessorDef()](request, index, count);
}