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


C# IObjectFacade.ToEnumerable方法代码示例

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


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

示例1: ListRepresentation

        protected ListRepresentation(IOidStrategy oidStrategy, IObjectFacade list, HttpRequestMessage req, RestControlFlags flags, ActionContextFacade actionContext)
            : base(oidStrategy, flags) {
            Value = list.ToEnumerable().Select(no => CreateObjectLink(oidStrategy, req, no, actionContext)).ToArray();

            SetLinks(req, actionContext);
            SetExtensions(oidStrategy, actionContext);
            SetHeader(false);
        }
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:8,代码来源:ListRepresentation.cs

示例2: CreateDefaultLinks

 private static object CreateDefaultLinks(IOidStrategy oidStrategy, HttpRequestMessage req, IActionParameterFacade parameter, IObjectFacade defaultNakedObject, string title, RestControlFlags flags) {
     if (defaultNakedObject.Specification.IsCollection) {
         return defaultNakedObject.ToEnumerable().Select(i => CreateDefaultLink(oidStrategy, req, parameter, i, i.TitleString, flags)).ToArray();
     }
     return CreateDefaultLink(oidStrategy, req, parameter, defaultNakedObject, title, flags);
 }
开发者ID:Robin--,项目名称:NakedObjectsFramework,代码行数:6,代码来源:ParameterRepresentation.cs

示例3: ExecuteAction

        private ActionResult ExecuteAction(ObjectAndControlData controlData, IObjectFacade nakedObject, IActionFacade action) {
            if (ActionExecutingAsContributed(action, nakedObject) && action.ParameterCount == 1) {
                // contributed action being invoked with a single parm that is the current target
                // no dialog - go straight through 

                var ac = new ArgumentsContextFacade {Values = new Dictionary<string, object>(), ValidateOnly = false};

                if (nakedObject.Specification.IsCollection && !nakedObject.Specification.IsParseable) {
                    var oids = nakedObject.ToEnumerable().Select(no => Facade.OidTranslator.GetOidTranslation(no)).ToArray();
                    var spec = nakedObject.ElementSpecification;

                    var ar = Facade.ExecuteListAction(oids, spec, action.Id, ac);
                    return AppropriateView(controlData, GetResult(ar), action);
                }
                else {
                    var oid = Facade.OidTranslator.GetOidTranslation(nakedObject);
                    var ar = Facade.ExecuteObjectAction(oid, action.Id, ac);

                    return AppropriateView(controlData, GetResult(ar), action);
                }
            }

            if (!action.Parameters.Any()) {
                var ac = new ArgumentsContextFacade {Values = new Dictionary<string, object>(), ValidateOnly = false};
                var oid = Facade.OidTranslator.GetOidTranslation(nakedObject);
                var result = Facade.ExecuteObjectAction(oid, action.Id, ac);

                return AppropriateView(controlData, GetResult(result), action);
            }

            SetDefaults(nakedObject, action);
            // do after any parameters set by contributed action so this takes priority
            SetSelectedParameters(action);
            SetPagingValues(controlData, nakedObject);
            var property = DisplaySingleProperty(controlData, controlData.DataDict);

            return View(property == null ? "ActionDialog" : "PropertyEdit", new FindViewModel {ContextObject = nakedObject.GetDomainObject(), ContextAction = action, PropertyName = property});
        }
开发者ID:priaonehaha,项目名称:NakedObjectsFramework,代码行数:38,代码来源:GenericControllerImpl.cs

示例4: 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

示例5: 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

示例6: CollectionTable

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

            string innerHtml = "";

            var collection = collectionNakedObject.ToEnumerable().ToArray();

            var collectionSpec = collectionNakedObject.ElementSpecification;

            var collectionAssocs = html.CollectionAssociations(collection, collectionSpec, filter, order);

            int index = 0;
            foreach (var 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(Encode(html.Facade().OidTranslator.GetOidTranslation(item)), defaultChecked, new { id, @class = IdConstants.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(html.IdHelper(), 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:priaonehaha,项目名称:NakedObjectsFramework,代码行数:54,代码来源:CommonHtmlHelper.cs

示例7: GetSelectedForChoice

        private static bool GetSelectedForChoice(this HtmlHelper html, IObjectFacade choice, IObjectFacade existingNakedObject) {
            IEnumerable<IObjectFacade> existingNakedObjects;

            if (existingNakedObject == null) {
                existingNakedObjects = new IObjectFacade[] { };
            } else if (existingNakedObject.Specification.IsParseable || !existingNakedObject.Specification.IsCollection) {
                // isParseable to catch strings 
                existingNakedObjects = new[] { existingNakedObject };
            } else {
                existingNakedObjects = existingNakedObject.ToEnumerable();
            }

            if (choice.Specification.IsEnum) {
                return existingNakedObjects.Any(no => no != null && choice.EnumIntegralValue == no.EnumIntegralValue);
            }

            if (choice.Specification.IsParseable) {
                return existingNakedObjects.Any(no => choice.TitleString.Trim() == no.TitleString.Trim());
            }
            return existingNakedObjects.Any(choice.Equals);
        }
开发者ID:priaonehaha,项目名称:NakedObjectsFramework,代码行数:21,代码来源:CommonHtmlHelper.cs


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