public override object[] GetChoices(INakedObjectAdapter nakedObjectAdapter, IDictionary <string, INakedObjectAdapter> parameterNameValues)
        {
            INakedObjectAdapter[] parms = FacetUtils.MatchParameters(parameterNames, parameterNameValues);

            try {
                var options = choicesDelegate(nakedObjectAdapter.GetDomainObject(), parms.Select(p => p.GetDomainObject()).ToArray()) as IEnumerable;
                if (options != null)
                {
                    return(options.Cast <object>().ToArray());
                }
                throw new NakedObjectDomainException(Log.LogAndReturn($"Must return IEnumerable from choices method: {choicesMethod.Name}"));
            }
            catch (ArgumentException ae) {
                throw new InvokeException(Log.LogAndReturn($"Choices exception: {choicesMethod.Name} has mismatched (ie type of choices parameter does not match type of action parameter) parameter types"), ae);
            }
        }
示例#2
0
 public object[] GetChoices(INakedObjectAdapter inObjectAdapter, IDictionary <string, INakedObjectAdapter> parameterNameValues)
 {
     INakedObjectAdapter[] parms = FacetUtils.MatchParameters(parameterNames, parameterNameValues);
     try {
         object options    = methodDelegate(inObjectAdapter.GetDomainObject(), parms.Select(p => p.GetDomainObject()).ToArray());
         var    enumerable = options as IEnumerable;
         if (enumerable != null)
         {
             return(enumerable.Cast <object>().ToArray());
         }
         throw new NakedObjectDomainException("Must return IEnumerable from choices method: " + method.Name);
     }
     catch (ArgumentException ae) {
         string msg = string.Format("Choices exception: {0} has mismatched (ie type of parameter does not match type of property) parameter types", method.Name);
         throw new InvokeException(msg, ae);
     }
 }
        public override object[] GetChoices(INakedObject nakedObject, IDictionary <string, INakedObject> parameterNameValues)
        {
            INakedObject[] parms = FacetUtils.MatchParameters(parameterNames, parameterNameValues);

            try {
                var options = InvokeUtils.Invoke(choicesMethod, nakedObject, parms) as IEnumerable;
                if (options != null)
                {
                    return(options.Cast <object>().ToArray());
                }
                throw new NakedObjectDomainException("Must return IEnumerable from choices method: " + choicesMethod.Name);
            }
            catch (ArgumentException ae) {
                string msg = string.Format("Choices exception: {0} has mismatched (ie type of choices parameter does not match type of action parameter) parameter types", choicesMethod.Name);
                throw new InvokeException(msg, ae);
            }
        }