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


C# INakedObject.GetTypeOfFacetFromSpec方法代码示例

本文整理汇总了C#中INakedObject.GetTypeOfFacetFromSpec方法的典型用法代码示例。如果您正苦于以下问题:C# INakedObject.GetTypeOfFacetFromSpec方法的具体用法?C# INakedObject.GetTypeOfFacetFromSpec怎么用?C# INakedObject.GetTypeOfFacetFromSpec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在INakedObject的用法示例。


在下文中一共展示了INakedObject.GetTypeOfFacetFromSpec方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CollectionTable

        private static string CollectionTable(this HtmlHelper html,
                                              INakedObject collectionNakedObject,
                                              Func<INakedObject, string> linkFunc,
                                              Func<INakedObjectAssociation, bool> filter,
                                              Func<INakedObjectAssociation, int> order,
                                              bool isStandalone,
                                              bool withSelection,
                                              bool withTitle,
                                              bool defaultChecked = false) {
            var table = new TagBuilder("table");
            table.AddCssClass(CollectionItemTypeName(collectionNakedObject));
            table.InnerHtml += Environment.NewLine;

            string innerHtml = "";

            INakedObject[] collection = collectionNakedObject.GetAsEnumerable().ToArray();
            INakedObjectSpecification collectionSpec = collectionNakedObject.GetTypeOfFacetFromSpec().ValueSpec;
            INakedObjectAssociation[] collectionAssocs = CollectionAssociations(collection, collectionSpec, filter, order);

            int index = 0;
            foreach (INakedObject item in collection) {
                var row = new TagBuilder("tr");

                if (withSelection) {
                    var cbTag = new TagBuilder("td");
                    int i = index++;
                    string id = "checkbox" + i;
                    string label = GetLabelTag(true, (i + 1).ToString(CultureInfo.InvariantCulture), () => id);
                    cbTag.InnerHtml += (label + html.CheckBox(FrameworkHelper.GetObjectId(item), defaultChecked, new {id, @class = IdHelper.CheckboxClass}));
                    row.InnerHtml += cbTag.ToString();
                }

                if (withTitle) {
                    var itemTag = new TagBuilder("td");
                    itemTag.InnerHtml += linkFunc(item);
                    row.InnerHtml += itemTag.ToString();
                }

               string[] collectionValues = collectionAssocs.Select(a => html.GetViewField(new PropertyContext(item, a, false), a.Description, true, true)).ToArray();

                foreach (string s in collectionValues) {
                    row.InnerHtml += new TagBuilder("td") {InnerHtml = s};
                }
                innerHtml += (row + Environment.NewLine);
            }

            var headers = collectionAssocs.Select(a => a.Name).ToArray();
            html.AddHeader(headers, table, isStandalone, withSelection, withTitle, defaultChecked);
            table.InnerHtml += innerHtml;

            return table + html.AddFooter(collectionNakedObject);
        }
开发者ID:,项目名称:,代码行数:52,代码来源:

示例2: AddFooter

        private static string AddFooter(this HtmlHelper html, INakedObject pagedCollectionNakedObject) {
            int pageSize, maxPage, currentPage, total;
            html.GetPagingValues(out pageSize, out maxPage, out currentPage, out total);

            if (maxPage > 1) {
                var tagPaging = new TagBuilder("div");
                tagPaging.AddCssClass(IdHelper.PagingClass);

                var tagPageNumber = new TagBuilder("div");
                tagPageNumber.AddCssClass(IdHelper.PageNumberClass);
                tagPageNumber.InnerHtml += string.Format(MvcUi.PageOf, currentPage, maxPage);
                tagPaging.InnerHtml += tagPageNumber;

                var tagTotalCount = new TagBuilder("div");
                tagTotalCount.AddCssClass(IdHelper.TotalCountClass);
                INakedObjectSpecification typeSpec = pagedCollectionNakedObject.GetTypeOfFacetFromSpec().ValueSpec;
                tagTotalCount.InnerHtml += string.Format(MvcUi.TotalOfXType, total, total == 1 ? typeSpec.SingularName : typeSpec.PluralName);
                tagPaging.InnerHtml += tagTotalCount;
                string displayType = html.ViewData.ContainsKey(IdHelper.CollectionFormat) ? (string) html.ViewData[IdHelper.CollectionFormat] : IdHelper.ListDisplayFormat;

                if (currentPage > 1) {
                    tagPaging.InnerHtml += GetSubmitButton(null, MvcUi.First, IdHelper.PageAction, new RouteValueDictionary(new {page = 1, pageSize, NofCollectionFormat = displayType}));
                    tagPaging.InnerHtml += GetSubmitButton(null, MvcUi.Previous, IdHelper.PageAction, new RouteValueDictionary(new {page = currentPage - 1, pageSize, NofCollectionFormat = displayType}));
                }
                else {
                    tagPaging.InnerHtml += GetDisabledButton(null, MvcUi.First);
                    tagPaging.InnerHtml += GetDisabledButton(null, MvcUi.Previous);
                }

                if (currentPage < maxPage) {
                    tagPaging.InnerHtml += GetSubmitButton(null, MvcUi.Next, IdHelper.PageAction, new RouteValueDictionary(new {page = currentPage + 1, pageSize, NofCollectionFormat = displayType}));
                    tagPaging.InnerHtml += GetSubmitButton(null, MvcUi.Last, IdHelper.PageAction, new RouteValueDictionary(new {page = maxPage, pageSize, NofCollectionFormat = displayType}));
                }
                else {
                    tagPaging.InnerHtml += GetDisabledButton(null, MvcUi.Next);
                    tagPaging.InnerHtml += GetDisabledButton(null, MvcUi.Last);
                }

                return tagPaging.ToString();
            }

            return "";
        }
开发者ID:,项目名称:,代码行数:43,代码来源:

示例3: CollectionItemTypeName

 private static string CollectionItemTypeName(INakedObject collectionNakedObject) {
     ITypeOfFacet facet = collectionNakedObject.GetTypeOfFacetFromSpec();
     return facet.ValueSpec.ShortName;
 }
开发者ID:,项目名称:,代码行数:4,代码来源:


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