本文整理汇总了C#中ElementRequest类的典型用法代码示例。如果您正苦于以下问题:C# ElementRequest类的具体用法?C# ElementRequest怎么用?C# ElementRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ElementRequest类属于命名空间,在下文中一共展示了ElementRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AwesomeFields
//returning a string is DUMB
public static string AwesomeFields(this IFubuPage page, object model)
{
var type = model.GetType();
var result = new StringBuilder();
var tags = page.Tags<AwesomeEditModel>();
var sl = page.Get<IServiceLocator>();
tags.SetProfile(AwesomeConfiguration.TagProfile);
foreach(var prop in getProperties(type))
{
var p = new SingleProperty(prop, type);
var elementRequest = new ElementRequest(model, p, sl);
var accessRight = page.Get<IFieldAccessService>().RightsFor(elementRequest);
var line = new FormLineExpression<AwesomeEditModel>(tags, tags.NewFieldLayout(), elementRequest)
.Access(accessRight)
.Editable(true);
result.Append(line.ToString());
}
return result.ToString();
}
示例2: modify
protected override void modify(ElementRequest request)
{
var rules = request.Get<ValidationGraph>().FieldRulesFor(request.Accessor);
var modifier = request.Get<IFieldValidationModifier>();
rules.Each(x => modifier.ModifyFor(x, request));
}
示例3: Build
public override void Build(ElementRequest request, HtmlTag tag)
{
tag
.AllTags()
.Where(t => t.IsInputElement())
.ForEach(t => t.AddClass("email"));
}
示例4: Build
public override HtmlTag Build(ElementRequest request)
{
var tag = new HtmlTag("div").Text(request.StringValue()).AddClass("editable").Id(request.Accessor.Name);
var options = new EditOptions();
if (request.Accessor.HasAttribute<MarkdownAttribute>())
{
tag.UnEncoded().Text(new Markdown().Transform(request.RawValue== null ? "" : request.RawValue.ToString()));
options.Markdown = true;
}
options.MultiLine = request.Accessor.Name == "Details";
options.RequiresExplicitUserActionForSave = true;
options.MaximumLength = request.Accessor.PropertyType.Equals(typeof(string)) ? Entity.UnboundedStringLength : 0;
options.IsDate = request.Accessor.PropertyType.IsDateTime();
options.IsTime = request.Accessor.Name.ToLower().Contains("time");
options.IsNumber = request.Accessor.PropertyType.IsIntegerBased() || request.Accessor.PropertyType.IsFloatingPoint();
options.Required = request.Accessor.HasAttribute<RequiredAttribute>();
options.PlaceholderText = "Double-Click to edit " + request.Accessor.Name.ToLower() + ".";
var data = options.ToJson();
tag.Attr("data", "{editoptions:"+data+"}");
return tag;
}
示例5: AddElementName
public static void AddElementName(ElementRequest request, HtmlTag tag)
{
if (tag.IsInputElement())
{
tag.Attr(HtmlAttributeConstants.Name, request.ElementId);
}
}
示例6: Build
public override HtmlTag Build(ElementRequest request)
{
Action<SelectTag> action = x =>
{
var value = request.RawValue;
var valueType = request.Accessor.PropertyType;
var repository = ObjectFactory.Container.GetInstance<IRepository>();
var getIdsFromPrincipal = ObjectFactory.Container.GetInstance<ISessionContext>();
repository.DisableFilter("TenantConditionFilter");
repository.DisableFilter("OrgConditionFilter");
var findAll = typeof(Repository).GetMethod("FindAll");
var genericFindAll = findAll.MakeGenericMethod(new []{valueType});
var lookupTypes = (IEnumerable<ILookupType>)genericFindAll.Invoke(repository, new object[] { });
var selectListItemService = ObjectFactory.Container.GetInstance<ISelectListItemService>();
var selectListItems = selectListItemService.CreateLookupList(lookupTypes, l => l.Name, l => l.EntityId, true);
repository.EnableFilter("OrgConditionFilter", "OrgId", getIdsFromPrincipal.GetOrgId());
//if (selectListItems == null) return;
selectListItems.Each(option => x.Option(option.Text, option.Value.IsNotEmpty() ? option.Value : ""));
if (value != null && value.ToString().IsNotEmpty())
{
var lookupType = value as ILookupType;
x.SelectByValue(lookupType.EntityId.ToString());
}
x.AddClass("mf_fixedWidthDropdown");
x.AddClass("fixedWidthDropdown");
};
return new SelectTag(action);
}
示例7: 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);
});
}
示例8: Build
public override HtmlTag Build(ElementRequest request)
{
PhoneNumber p = request.Accessor.GetValue(request.Model) as PhoneNumber;
string str = string.Format("({0}) {1}-{2}", p.AreaCode, p.Prefix, p.Suffix);
return new HtmlTag("span").Text(str);
}
示例9: Build
public static HtmlTag Build(ElementRequest request)
{
var numberOfRows = 6;
int? numberOfColumns = null;
var attribute = request.Accessor.GetAttribute<MultilineAttribute>();
if (attribute != null)
{
if (attribute.NumberOfRows.HasValue)
{
numberOfRows = attribute.NumberOfRows.Value;
}
if (attribute.NumberOfColumns.HasValue)
{
numberOfColumns = attribute.NumberOfColumns.Value;
}
}
var textArea = new TextAreaTag()
.Rows(numberOfRows);
if (numberOfColumns.HasValue)
{
textArea.Cols(numberOfColumns.Value);
}
return textArea
.Id(request.ElementId)
.Attr(HtmlAttributeConstants.Name, request.ElementId)
.Text(request.StringValue());
}
示例10: Build
public override void Build(ElementRequest request, HtmlTag tag)
{
// todo can we narrow down for numbers that it's a whole number (probably need a regex to allow commas too)
tag.AllTags()
.Where(t => t.IsInputElement())
.ForEach(t => t.AddClass("number"));
}
示例11: 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);
}
示例12: BuildTag
protected override HtmlTag BuildTag(ElementRequest request)
{
var label = LabelingConvention.GetLabelText(request.Accessor);
return Tags.Span
.Text(label);
}
示例13: SetSelectedValue
private static void SetSelectedValue(ElementRequest request, SelectTag select)
{
if (!request.ValueIsEmpty())
{
select.SelectByValue(request.Value<int>().ToString());
}
}
示例14: Build
public override HtmlTag Build(ElementRequest request)
{
Action<SelectTag> action = x =>
{
var value = request.RawValue;
Enumeration enumeration = request.Accessor.InnerProperty.GetEnumeration("");
if (enumeration == null) return;
IEnumerable<Enumeration> enumerations = Enumeration.GetAllActive(enumeration);
if (enumerations == null) return;
enumerations = enumerations.OrderBy(item => item.Key);
foreach (Enumeration option in enumerations)
{
x.Option(option.Key,
option.Value ?? option.Key);
}
if (value != null && value.ToString().IsNotEmpty())
{
x.SelectByValue(value);
}
else
{
Enumeration defaultOption = enumerations.FirstOrDefault(o => o.IsDefault);
if (defaultOption != null)
{
x.SelectByValue(defaultOption.Value.IsEmpty() ? defaultOption.Key : defaultOption.Value);
}
}
};
return new SelectTag(action);
}
示例15: PlanFor
public ITagPlan PlanFor(ElementRequest subject, string profile = null, string category = null)
{
profile = profile ?? TagConstants.Default;
category = category ?? TagConstants.Default;
return _categories[category].PlanFor(subject, profile);
}