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


C# IObjectFacade.Count方法代码示例

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

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

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

示例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;
        }
开发者ID:priaonehaha,项目名称:NakedObjectsFramework,代码行数:11,代码来源:NakedObjectsController.cs

示例5: SetPagingValues

 internal void SetPagingValues(ObjectAndControlData controlData, IObjectFacade nakedObject) {
     if (nakedObject.Specification.IsCollection) {
         int sink1, sink2;
         CurrentlyPaging(controlData, nakedObject.Count(), out sink1, out sink2);
     }
 }
开发者ID:priaonehaha,项目名称:NakedObjectsFramework,代码行数:6,代码来源:NakedObjectsController.cs


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