本文整理汇总了C#中ElementRequest.Value方法的典型用法代码示例。如果您正苦于以下问题:C# ElementRequest.Value方法的具体用法?C# ElementRequest.Value怎么用?C# ElementRequest.Value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElementRequest
的用法示例。
在下文中一共展示了ElementRequest.Value方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildTag
protected override HtmlTag BuildTag(ElementRequest request)
{
var attribute = GetCheckBoxListAttribute(request);
var tag = attribute.Horizontal ? Tags.Span : Tags.Div;
var optionPairs = GetOptionPairs(request, attribute);
var checkedOptions = request.Value<IList<int>>().Cast<object>();
var groupName = request.ElementId;
foreach (var option in optionPairs)
{
var isChecked = checkedOptions.Contains(option.Value);
var label = Tags.Label.For(groupName).Text(option.Text);
var checkBox = Tags.Checkbox(isChecked).Name(groupName).Value(option.Value);
tag.Nest(
Tags.Div.Nest(
Tags.Span
.AddClass(OptionSpanClass)
.AddClass(attribute.Horizontal ? OptionHorizontalSpanClass : string.Empty)
.Nest(
label,
checkBox
)));
}
return tag
.AddClass(CheckBoxesClass);
}
示例2: BuildTag
protected override HtmlTag BuildTag(ElementRequest req)
{
var attrib = GetCheckBoxListAttribute(req);
var optionPairs = GetOptionPairs(req, attrib);
var checkedOptions = req.Value<IList<int>>().Cast<object>();
var groupName = req.ElementId;
var div = attrib.Horizontal ? Tags.Span : Tags.Div;
foreach (var item in optionPairs)
{
var isChecked = checkedOptions.Contains(item.Value);
var label = Tags.Label.For(groupName).Text(item.Text);
var checkBox = Tags.Checkbox(isChecked).Name(groupName).Value(item.Value);
div.Nest(
Tags.Div.Nest(
Tags.Span
.AddClass("option")
.AddClass(attrib.Horizontal ? "horizontalOption" : "")
.Nest(
label,
checkBox
)));
}
return div.AddClass("checkboxes");
}
示例3: SetSelectedValue
private static void SetSelectedValue(ElementRequest request, SelectTag select)
{
if (!request.ValueIsEmpty())
{
select.SelectByValue(request.Value<int>().ToString());
}
}
示例4: Build
public override HtmlTag Build(ElementRequest request)
{
var name = request.Accessor.Name;
var pair = request.Value<AutoCompleteInput>();
var textBoxId = name + "Text";
var textBox = Tags.Input
.Attr(HtmlAttributeConstants.Type, "Text")
.Id(textBoxId)
.Value(pair.Text)
.Attr(HtmlAttributeConstants.Name, textBoxId);
var valueBoxId = name + "Value";
var valueBox = Tags.Hidden
.Id(valueBoxId)
.Value(pair.Value)
.Attr(HtmlAttributeConstants.Name, valueBoxId);
var createScript = GetCreateScript(textBoxId, pair.Url);
var resultScript = GetResultScript(textBoxId, valueBoxId);
return Tags.Span.Nest(
textBox,
valueBox,
createScript,
resultScript
);
}
示例5: Build
public override HtmlTag Build(ElementRequest request)
{
var attr = request.Accessor.GetAttribute<ValueOfAttribute>();
var value = ValueObjectRegistry.GetValueObjectHolder(attr.Name);
if (value == null) return new TextboxTag(request.ElementId, request.Value<string>());
var defaultValue = "";
if (request.RawValue != null)
{
defaultValue = request.RawValue.ToString();
}
if (defaultValue.IsEmpty())
{
ValueObject @default = value.Values.FirstOrDefault(x => x.IsDefault);
if (@default != null) defaultValue = @default.Key;
}
return new SelectTag(tag =>
{
tag.TopOption(string.Format("-- Select {0} --", value.GetKey()), null);
value.Values.Each(vo => tag.Option(vo.Value, vo.Key));
tag.SelectByValue(defaultValue);
});
}
示例6: BuildTag
protected override HtmlTag BuildTag(ElementRequest request)
{
var isChecked = request.Value<bool>();
return Tags.Checkbox(isChecked)
.Value(CheckBoxValueWhenChecked)
.Id(request.ElementId);
}
示例7: CheckBoxBuilder
public static HtmlTag CheckBoxBuilder(ElementRequest request)
{
var isChecked = request.Value<bool>();
var tag = new CheckboxTag(isChecked);
tag.Attr("name", request.Accessor.Name);
tag.AddClass("checkbox");
return tag;
}
示例8: GetValue
private MonthOfYear GetValue(ElementRequest request)
{
var value = MonthOfYear.Current;
if (!request.ValueIsEmpty())
{
value = request.Value<MonthOfYear>();
}
return value;
}
示例9: GetNamesOfFlagsThatAreSet
private IEnumerable<string> GetNamesOfFlagsThatAreSet(ElementRequest request)
{
var value = request.Value<int>();
var flagsEnumType = RemoveNullableIfNecessary(request.Accessor.PropertyType);
return EnumHelper
.GetOptions(flagsEnumType)
.Where(o => ValueHasOptionSet(value, o))
.Select(o => o.Name);
}
示例10: BuildTag
protected override HtmlTag BuildTag(ElementRequest request)
{
var tag = Tags.Span;
if (request.ValueIsEmpty())
{
return tag;
}
var value = request.Value<DateTime>();
tag.Text(value.ToShortDateString());
return tag;
}
示例11: BuildDisplay
public static HtmlTag BuildDisplay(ElementRequest request)
{
var time = request.Value<Time>();
var baseName = request.Accessor.Name;
var tag = new HtmlTag("span", c =>
{
c.Append(BuildTimeElementDisplayTag(baseName + Minutes, time.Minutes, "##"));
c.Append(new LiteralTag(":"));
c.Append(BuildTimeElementDisplayTag(baseName + Seconds, time.Seconds, "0#.#"));
});
return tag;
}
示例12: BuildTag
protected override HtmlTag BuildTag(ElementRequest request)
{
var tag = new CalendarTextBox(request.ElementId);
if (request.ValueIsEmpty())
{
return tag;
}
var value = request.Value<DateTime>();
return tag.SetDate(value);
}
示例13: buildOptions
private static void buildOptions(ElementRequest request, SelectTag tag)
{
var listElements = GetListElementTitlesOrderedByRank(request);
listElements.ElementTitles.Each(title => tag.Option(title, title));
var requestValue = request.Value<string>();
var defaultValue = requestValue.IsNotEmpty() ? requestValue : listElements.DefaultElementTitle;
tag.SelectByValue(defaultValue);
}
示例14: BuildTag
protected override HtmlTag BuildTag(ElementRequest request)
{
var tag = Tags.Span;
if (request.ValueIsEmpty())
{
return tag;
}
var value = request.Value<int>();
var type = RemoveNullableIfNecessary(request.Accessor.PropertyType);
var options = EnumHelper.GetOptions(type);
var values = options.Where(o => (value & (int) o.GetValue(null)) > 0).Select(o => o.Name).ToArray();
tag.Text(String.Join(", ", values));
return tag;
}
示例15: BuildOptions
private Action<SelectTag> BuildOptions(ElementRequest req)
{
var hasBlankOption = req.Accessor.HasAttribute<WithBlankOption>();
return tag =>
{
var options = GetOptions(req);
if (hasBlankOption)
{
tag.Option("", "");
}
foreach (var f in options)
{
tag.Option(GetText(f, req), f.GetRawConstantValue().ToString());
}
if (!req.ValueIsEmpty())
{
tag.SelectByValue(req.Value<int>().ToString());
}
};
}