Exemplo n.º 1
0
        /// <summary>
        /// Binds the return value to the UI.
        /// </summary>
        /// <param name="outcome">The outcome or processing the message.</param>
        public virtual IResult CreateResult(MessageProcessingOutcome outcome)
        {
            if (outcome.ResultType == typeof(void))
            {
                return(new EmptyResult());
            }

            if (typeof(Task).IsAssignableFrom(outcome.ResultType))
            {
                if (outcome.ResultType.IsGenericType)
                {
                    var method = GetType().GetMethod("GetGenericTaskResult", BindingFlags.Instance | BindingFlags.NonPublic)
                                 .MakeGenericMethod(outcome.ResultType.GetGenericArguments());
                    return(new SequentialResult((IEnumerable <IResult>)method.Invoke(this, new[] { outcome.Result })));
                }
                return(((Task)outcome.Result).AsResult());
            }

            if (outcome.Result is IEnumerable <IResult> )
            {
                return(new SequentialResult(((IEnumerable <IResult>)outcome.Result).GetEnumerator()));
            }

            if (outcome.Result is IEnumerator <IResult> )
            {
                return(new SequentialResult((IEnumerator <IResult>)outcome.Result));
            }

            if (outcome.Result is IResult)
            {
                return(new SequentialResult(new List <IResult> {
                    (IResult)outcome.Result
                }.GetEnumerator()));
            }

            return(new DefaultResult(conventionManager, outcome));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultResult"/> class.
 /// </summary>
 /// <param name="conventionManager">The convention manager.</param>
 /// <param name="outcome">The outcome of processing the message.</param>
 public DefaultResult(IConventionManager conventionManager, MessageProcessingOutcome outcome)
 {
     _conventionManager = conventionManager;
     _outcome = outcome;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultResult"/> class.
 /// </summary>
 /// <param name="conventionManager">The convention manager.</param>
 /// <param name="outcome">The outcome of processing the message.</param>
 public DefaultResult(IConventionManager conventionManager, MessageProcessingOutcome outcome)
 {
     this.conventionManager = conventionManager;
     this.outcome           = outcome;
 }