public int Count(INakedObjectSurface target) { if (IsCollection) { INakedObject result = assoc.GetNakedObject(((NakedObjectWrapper)target).WrappedNakedObject); return(result.GetCollectionFacetFromSpec().AsQueryable(result).Count()); } return(0); }
public int CountField(INakedObject nakedObject, string field) { Log.DebugFormat("CountField nakedObject: {0} field: {1}", nakedObject, field); var spec = nakedObject.Spec as IObjectSpec; Trace.Assert(spec != null); IAssociationSpec associationSpec = spec.Properties.Single(x => x.Id == field); if (nakedObject.Spec.IsViewModel) { INakedObject collection = associationSpec.GetNakedObject(nakedObject); return(collection.GetCollectionFacetFromSpec().AsEnumerable(collection, nakedObjectManager).Count()); } return(objectStore.CountField(nakedObject, associationSpec)); }
private void InitObjectSetupCollection(INakedObject nakedObject, ObjectData data, INakedObjectAssociation field) { /* * The internal collection is already a part of the object, and therefore cannot be recreated, but its * oid must be set */ IList <IOid> refs = (IList <IOid>)data.GetField(field.Id) ?? new List <IOid>(); INakedObject collection = field.GetNakedObject(nakedObject); collection.ResolveState.Handle(Events.StartResolvingEvent); var elements = new List <INakedObject>(); foreach (IOid elementOid in refs) { INakedObject adapter = Persistor.GetAdapterFor(elementOid) ?? GetObject(elementOid, null); elements.Add(adapter); } ICollectionFacet facet = collection.GetCollectionFacetFromSpec(); facet.Init(collection, elements.ToArray()); collection.ResolveState.Handle(Events.EndResolvingEvent); }
public static IQueryable GetAsQueryable(this INakedObject objectRepresentingCollection) { return(objectRepresentingCollection.GetCollectionFacetFromSpec().AsQueryable(objectRepresentingCollection)); }
public static IEnumerable <INakedObject> GetAsEnumerable(this INakedObject objectRepresentingCollection, INakedObjectManager manager) { return(objectRepresentingCollection.GetCollectionFacetFromSpec().AsEnumerable(objectRepresentingCollection, manager)); }
internal INakedObject Page(INakedObject nakedObject, int collectionSize, ObjectAndControlData controlData, bool forceEnumerable) { int page, pageSize; var collectionfacet = nakedObject.GetCollectionFacetFromSpec(); if (CurrentlyPaging(controlData, collectionSize, out page, out pageSize) && !nakedObject.IsPaged()) { return DoPaging(nakedObject, collectionfacet, page, pageSize, forceEnumerable); } // one page of full collection return DoPaging(nakedObject, collectionfacet, 1, collectionSize, forceEnumerable); }
private static INakedObject Page(INakedObject objectRepresentingCollection, int page, int size) { return objectRepresentingCollection.GetCollectionFacetFromSpec().Page(page, size, objectRepresentingCollection, true); }
private INakedObject Page(INakedObject objectRepresentingCollection, int page, int size) { return(objectRepresentingCollection.GetCollectionFacetFromSpec().Page(page, size, objectRepresentingCollection, framework.NakedObjectManager, true)); }
private static bool GetSelectedForChoice(INakedObject choice, INakedObject existingNakedObject) { IEnumerable<INakedObject> existingNakedObjects; if (existingNakedObject == null) { existingNakedObjects = new INakedObject[] {}; } else if (existingNakedObject.Specification.IsParseable || !existingNakedObject.Specification.IsCollection) { // isParseable to catch strings existingNakedObjects = new[] {existingNakedObject}; } else { existingNakedObjects = existingNakedObject.GetCollectionFacetFromSpec().AsEnumerable(existingNakedObject); } var enumFacet = choice.Specification.GetFacet<IEnumValueFacet>(); if (enumFacet != null) { return existingNakedObjects.Any(no => no != null && enumFacet.IntegralValue(choice) == enumFacet.IntegralValue(no)); } if (choice.Specification.IsParseable) { return existingNakedObjects.Any(no => choice.TitleString() == no.TitleString()); } return existingNakedObjects.Any(no => choice == no); }