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


C# INakedObject.GetAsEnumerable方法代码示例

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


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

示例1: MakeCollectionPersistent

 private void MakeCollectionPersistent(INakedObject collection, IPersistedObjectAdder persistor) {
     if (collection.ResolveState.IsPersistent() || collection.Specification.Persistable == Persistable.TRANSIENT) {
         return;
     }
     Log.Info("persist " + collection);
     if (collection.ResolveState.IsTransient()) {
         collection.ResolveState.Handle(Events.StartResolvingEvent);
         collection.ResolveState.Handle(Events.EndResolvingEvent);
     }
     persistor.MadePersistent(collection);
     collection.GetAsEnumerable().ForEach(no => MakePersistent(no, persistor));
 }
开发者ID:radi4music,项目名称:NakedObjectsFramework,代码行数:12,代码来源:EntityPersistAlgorithm.cs

示例2: MakePersistent

        public virtual void MakePersistent(INakedObject nakedObject, IPersistedObjectAdder persistor) {
            if (nakedObject.Specification.IsCollection) {
                Log.Info("Persist " + nakedObject);

                nakedObject.GetAsEnumerable().ForEach(no => Persist(no, persistor));

                if (nakedObject.ResolveState.IsGhost()) {
                    nakedObject.ResolveState.Handle(Events.StartResolvingEvent);
                    nakedObject.ResolveState.Handle(Events.EndResolvingEvent);
                }
            }
            else {
                if (nakedObject.ResolveState.IsPersistent()) {
                    throw new NotPersistableException("can't make object persistent as it is already persistent: " + nakedObject);
                }
                if (nakedObject.Specification.Persistable == Persistable.TRANSIENT) {
                    throw new NotPersistableException("can't make object persistent as it is not persistable: " + nakedObject);
                }
                Persist(nakedObject, persistor);
            }
        }
开发者ID:radi4music,项目名称:NakedObjectsFramework,代码行数:21,代码来源:DefaultPersistAlgorithm.cs

示例3: AddInternalCollection

        public virtual void AddInternalCollection(INakedObject collection, string fieldId, bool ensurePersistent) {
            InitCollection(fieldId);

            foreach (INakedObject element in collection.GetAsEnumerable()) {
                IOid elementOid = element.Oid;
                if (elementOid == null) {
                    throw new Exception("Element is not persistent " + element);
                }

                AddElement(fieldId, elementOid);
            }
        }
开发者ID:NakedObjectsGroup,项目名称:NakedObjects.Contrib,代码行数:12,代码来源:ObjectData.cs

示例4: FilterCollection

        internal INakedObject FilterCollection(INakedObject nakedObject, ObjectAndControlData controlData) {
            var form = controlData.Form;
            if (form != null && nakedObject != null && nakedObject.Specification.IsCollection && nakedObject.Oid is CollectionMemento) {
                nakedObject = Page(nakedObject, nakedObject.GetAsQueryable().Count(), controlData, false);
                var map = nakedObject.GetAsEnumerable().ToDictionary(FrameworkHelper.GetObjectId, y => y.Object);
                var selected = map.Where(kvp => form.Keys.Cast<string>().Contains(kvp.Key) && form[kvp.Key].Contains("true")).Select(kvp => kvp.Value).ToArray();
                return CloneAndPopulateCollection(nakedObject, selected, false);
            }

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

示例5: SetPagingValues

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

示例6: IsObjectCompleteAndSaved

 private bool IsObjectCompleteAndSaved(INakedObject fieldTarget) {
     if (fieldTarget.Specification.IsCollection) {         
         if (fieldTarget.GetAsEnumerable().Any(no => !IsReferenceValidToPersist(no))) {
             ModelState.AddModelError("", MvcUi.CollectionIncomplete);
             return false;
         }
     }
     else {
         if (!IsReferenceValidToPersist(fieldTarget)) {
             ModelState.AddModelError("", MvcUi.ObjectIncomplete);
             return false;
         }
     }
  
     return true;
 }
开发者ID:,项目名称:,代码行数:16,代码来源:

示例7: SetNofCollection

        // Adds <code>nof:feature=&quot;collection&quot;</code> attribute, the
        // <code>nof:type=&quote;...&quot;</code> and the
        // <code>nof:size=&quote;...&quot;</code> for the supplied element.

        public static void SetNofCollection(XElement element,
                                            string prefix,
                                            string fullyQualifiedClassName,
                                            INakedObject collection) {
            SetAttribute(element, "feature", NofMetamodelFeatureCollection);
            SetAttribute(element, "type", prefix + ":" + fullyQualifiedClassName);
            SetAttribute(element, "size", "" + collection.GetAsEnumerable().Count());
        }
开发者ID:,项目名称:,代码行数:12,代码来源:

示例8: SetResolveStateForDerivedCollections

 private void SetResolveStateForDerivedCollections(INakedObject adapterFor) {
     bool isDerived = !IsPersisted;
     if (isDerived && !adapterFor.ResolveState.IsResolved()) {
         if (adapterFor.GetAsEnumerable().Any()) {
             adapterFor.ResolveState.Handle(Events.StartResolvingEvent);
             adapterFor.ResolveState.Handle(Events.EndResolvingEvent);
         }
     }
 }
开发者ID:radi4music,项目名称:NakedObjectsFramework,代码行数:9,代码来源:OneToManyAssociationImpl.cs

示例9: TestCollection

 public TestCollection(INakedObject collection, ITestObjectFactory factory) {
     this.collection = collection;
     wrappedCollection = collection.GetAsEnumerable().Select(factory.CreateTestObject);
 }
开发者ID:,项目名称:,代码行数:4,代码来源:

示例10: 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,代码来源:


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