示例#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);
        }