Example #1
0
        public INakedObjectAdapter[] GetChoices(INakedObjectAdapter nakedObjectAdapter, IDictionary <string, INakedObjectAdapter> parameterNameValues)
        {
            var choicesFacet = GetFacet <IActionChoicesFacet>();
            var enumFacet    = GetFacet <IEnumFacet>();

            if (choicesFacet != null)
            {
                object[] options = choicesFacet.GetChoices(parentAction.RealTarget(nakedObjectAdapter), parameterNameValues);
                if (enumFacet == null)
                {
                    return(manager.GetCollectionOfAdaptedObjects(options).ToArray());
                }

                return(manager.GetCollectionOfAdaptedObjects(enumFacet.GetChoices(parentAction.RealTarget(nakedObjectAdapter), options)).ToArray());
            }

            if (enumFacet != null)
            {
                return(manager.GetCollectionOfAdaptedObjects(enumFacet.GetChoices(parentAction.RealTarget(nakedObjectAdapter))).ToArray());
            }

            if (Spec.IsBoundedSet())
            {
                return(manager.GetCollectionOfAdaptedObjects(persistor.Instances(Spec)).ToArray());
            }

            if (Spec.IsCollectionOfBoundedSet(ElementSpec) || Spec.IsCollectionOfEnum(ElementSpec))
            {
                var         elementEnumFacet = ElementSpec.GetFacet <IEnumFacet>();
                IEnumerable domainObjects    = elementEnumFacet != null ? (IEnumerable)elementEnumFacet.GetChoices(parentAction.RealTarget(nakedObjectAdapter)) : persistor.Instances(ElementSpec);
                return(manager.GetCollectionOfAdaptedObjects(domainObjects).ToArray());
            }

            return(null);
        }
Example #2
0
 public bool IsFinderMethodFor(IObjectSpecImmutable spec)
 {
     if (!IsFinderMethod)
     {
         return(false);
     }
     if (ReturnSpec.IsCollection && ElementSpec.IsOfType(spec))
     {
         return(true);
     }
     return(ReturnSpec.IsOfType(spec));
 }
 public bool IsFinderMethodFor(IObjectSpecImmutable spec)
 {
     return(IsFinderMethod && (ReturnSpec.IsOfType(spec) || (ReturnSpec.IsCollection && ElementSpec.IsOfType(spec))));
 }