本文整理汇总了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);
}
示例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 "";
}
示例3: CollectionItemTypeName
private static string CollectionItemTypeName(INakedObject collectionNakedObject) {
ITypeOfFacet facet = collectionNakedObject.GetTypeOfFacetFromSpec();
return facet.ValueSpec.ShortName;
}