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


C# ElementRequest.ToAccessorDef方法代码示例

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

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

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

示例4: Build

 public HtmlTag Build(ElementRequest request)
 {
     return _creators[request.ToAccessorDef()](request);
 }
开发者ID:roend83,项目名称:fubumvc,代码行数:4,代码来源:TagFactory.cs

示例5: Build

 public override HtmlTag Build(ElementRequest request)
 {
     var accessorDef = request.ToAccessorDef();
     var literalList = accessorDef.Accessor.PropertyType.GetGenericArguments().Single();
     return BuildTag(request, literalList);
 }
开发者ID:wenyanw,项目名称:SystemStateExample,代码行数:6,代码来源:ListValueElementPolicy.cs

示例6: Build

 public HtmlTag Build(ElementRequest request, int index, int count)
 {
     return _creators[request.ToAccessorDef()](request, index, count);
 }
开发者ID:roend83,项目名称:fubumvc,代码行数:4,代码来源:PartialTagFactory.cs


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