当前位置: 首页>>代码示例>>C#>>正文


C# ElementRequest类代码示例

本文整理汇总了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();
        }
开发者ID:KevM,项目名称:awesomesauce,代码行数:26,代码来源:AwesomeFubuPageExtensions.cs

示例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));
        }
开发者ID:joemcbride,项目名称:fubuvalidation,代码行数:7,代码来源:FieldValidationElementModifier.cs

示例3: Build

 public override void Build(ElementRequest request, HtmlTag tag)
 {
     tag
         .AllTags()
         .Where(t => t.IsInputElement())
         .ForEach(t => t.AddClass("email"));
 }
开发者ID:phoenixwebgroup,项目名称:DotNetExtensions,代码行数:7,代码来源:EmailValidationModifier.cs

示例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;
        }
开发者ID:rauhryan,项目名称:kokugen,代码行数:27,代码来源:EditInPlaceBuilder.cs

示例5: AddElementName

 public static void AddElementName(ElementRequest request, HtmlTag tag)
 {
     if (tag.IsInputElement())
     {
         tag.Attr(HtmlAttributeConstants.Name, request.ElementId);
     }
 }
开发者ID:phoenixwebgroup,项目名称:Accountability,代码行数:7,代码来源:HtmlConventions.cs

示例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);
        }
开发者ID:reharik,项目名称:MethodFitness,代码行数:32,代码来源:SelectFromLookupTypeBuilder.cs

示例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);
                                     });
        }
开发者ID:rauhryan,项目名称:kokugen,代码行数:26,代码来源:ValueObjectDropdownBuilder.cs

示例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);
        }
开发者ID:randrews,项目名称:dovetail,代码行数:7,代码来源:PhoneNumberDisplayConvention.cs

示例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());
        }
开发者ID:phoenixwebgroup,项目名称:DotNetExtensions,代码行数:29,代码来源:TextAreaBuilder.cs

示例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"));
 }
开发者ID:phoenixwebgroup,项目名称:DotNetExtensions,代码行数:7,代码来源:NumericValidationModifier.cs

示例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);
        }
开发者ID:phoenixwebgroup,项目名称:DotNetExtensions,代码行数:28,代码来源:CheckBoxListBuilder.cs

示例12: BuildTag

        protected override HtmlTag BuildTag(ElementRequest request)
        {
            var label = LabelingConvention.GetLabelText(request.Accessor);

            return Tags.Span
                .Text(label);
        }
开发者ID:phoenixwebgroup,项目名称:DotNetExtensions,代码行数:7,代码来源:DefaultLabeler.cs

示例13: SetSelectedValue

 private static void SetSelectedValue(ElementRequest request, SelectTag select)
 {
     if (!request.ValueIsEmpty())
     {
         select.SelectByValue(request.Value<int>().ToString());
     }
 }
开发者ID:phoenixwebgroup,项目名称:DotNetExtensions,代码行数:7,代码来源:EnumDropDownBuilder.cs

示例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);
        }
开发者ID:reharik,项目名称:KnowYourTurf,代码行数:31,代码来源:SelectFromEnumerationBuilder.cs

示例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);
        }
开发者ID:calebjenkins,项目名称:htmltags,代码行数:7,代码来源:TagLibrary.cs


注:本文中的ElementRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。