本文整理汇总了C#中IObjectFacade.Count方法的典型用法代码示例。如果您正苦于以下问题:C# IObjectFacade.Count方法的具体用法?C# IObjectFacade.Count怎么用?C# IObjectFacade.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IObjectFacade
的用法示例。
在下文中一共展示了IObjectFacade.Count方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetPagination
// custom extension for pagination
private void SetPagination(IObjectFacade list, RestControlFlags flags) {
Pagination = new MapRepresentation();
var totalCount = list.Count();
var pageSize = flags.PageSize ;
var page = flags.Page;
var numPages = (int)Math.Round(totalCount / (decimal)pageSize + 0.5m);
numPages = numPages == 0 ? 1 : numPages;
var exts = new Dictionary<string, object> {
{"page", page},
{"pageSize", pageSize},
{"numPages", numPages},
{"totalCount", totalCount}
};
Pagination = RestUtils.CreateMap(exts);
}
示例2: SetPagination
// custom extension for pagination
private void SetPagination(IObjectFacade list, RestControlFlags flags, ActionContextFacade actionContext) {
Pagination = new MapRepresentation();
var totalCount = list.Count();
var pageSize = PageSize(flags, actionContext);
var page = flags.Page;
var numPages = (int) Math.Round(totalCount/(decimal) pageSize + 0.5m);
numPages = numPages == 0 ? 1 : numPages;
var exts = new Dictionary<string, object> {
{JsonPropertyNames.Page, page},
{JsonPropertyNames.PageSize, pageSize},
{JsonPropertyNames.NumPages, numPages},
{JsonPropertyNames.TotalCount, totalCount}
};
Pagination = RestUtils.CreateMap(exts);
}
示例3: AppropriateView
internal ActionResult AppropriateView(ObjectAndControlData controlData, IObjectFacade nakedObject, IActionFacade action = null, string propertyName = null) {
if (nakedObject == null) {
// no object to go to
// if action on object go to that object.
// if action on collection go to collection
// if action on service go to last object
nakedObject = controlData.GetNakedObject(Facade);
if (nakedObject.Specification.IsService) {
object lastObject = Session.LastObject(Facade, ObjectCache.ObjectFlag.BreadCrumb);
if (lastObject == null) {
return RedirectHome();
}
nakedObject = Facade.GetObject(lastObject);
}
if (nakedObject.IsCollectionMemento) {
// if we have returned null and existing object is collection memento need to make
// sure action remains action from original collectionMemento.
action = nakedObject.MementoAction;
}
}
if (nakedObject.Specification.IsCollection && !nakedObject.Specification.IsParseable) {
int collectionSize = nakedObject.Count();
if (collectionSize == 1) {
// remove any paging data - to catch case where custom page has embedded standalone collection as paging data will confuse rendering
ViewData.Remove(IdConstants.PagingData);
// is this safe TODO !!
return View("ObjectView", nakedObject.ToEnumerable().First().GetDomainObject());
}
nakedObject = Page(nakedObject, collectionSize, controlData);
// todo is there a better way to do this ?
action = action ?? nakedObject.MementoAction;
int page, pageSize;
CurrentlyPaging(controlData, collectionSize, out page, out pageSize);
var format = ViewData["NofCollectionFormat"] as string;
return View("StandaloneTable", ActionResultModel.Create(Facade, action, nakedObject, page, pageSize, format));
}
// remove any paging data - to catch case where custom page has embedded standalone collection as paging data will confuse rendering
ViewData.Remove(IdConstants.PagingData);
if (controlData.DataDict.Values.Contains("max")) {
// maximizing an inline object - do not update history
ViewData.Add("updateHistory", false);
}
return propertyName == null ? View(nakedObject.IsNotPersistent ? "ObjectView" : "ViewNameSetAfterTransaction", nakedObject.GetDomainObject()) :
View(nakedObject.IsNotPersistent ? "PropertyView" : "ViewNameSetAfterTransaction", new PropertyViewModel(nakedObject.GetDomainObject(), propertyName));
}
示例4: FilterCollection
internal IObjectFacade FilterCollection(IObjectFacade nakedObject, ObjectAndControlData controlData) {
var form = controlData.Form;
if (form != null && nakedObject != null && nakedObject.Specification.IsCollection) {
nakedObject = Page(nakedObject, nakedObject.Count(), controlData);
var map = nakedObject.ToEnumerable().ToDictionary(x => Facade.OidTranslator.GetOidTranslation(x).Encode(), y => y.GetDomainObject<object>());
var selected = map.Where(kvp => form.Keys.Cast<string>().Contains(kvp.Key) && form[kvp.Key].Contains("true")).Select(kvp => kvp.Value).ToArray();
return nakedObject.Select(selected, false);
}
return nakedObject;
}
示例5: SetPagingValues
internal void SetPagingValues(ObjectAndControlData controlData, IObjectFacade nakedObject) {
if (nakedObject.Specification.IsCollection) {
int sink1, sink2;
CurrentlyPaging(controlData, nakedObject.Count(), out sink1, out sink2);
}
}