Exemple #1
0
        /// <summary>
        /// Creates the a response with the specified status code when the rule's condition is met.
        /// </summary>
        /// <param name="self">The IThenable.</param>
        /// <param name="statusCode">The result factory.</param>
        /// <exception cref="System.ArgumentNullException">self</exception>
        public static void Then(this IThenable self, HttpStatusCode statusCode)
        {
            if (self == null)
            {
                throw new ArgumentNullException(nameof(self));
            }

            self.Then(x => new HttpResponseMessage(statusCode));
        }
Exemple #2
0
        /// <summary>
        /// Creates the action to run when the rule's condition is met.
        /// </summary>
        /// <param name="self">The IThenable.</param>
        /// <param name="resultFactory">The result factory.</param>
        /// <exception cref="System.ArgumentNullException">
        /// self
        /// or
        /// resultFactory
        /// </exception>
        public static void Then(this IThenable self, Func <HttpRequestMessage, HttpResponseMessage> resultFactory)
        {
            if (self == null)
            {
                throw new ArgumentNullException(nameof(self));
            }
            if (resultFactory == null)
            {
                throw new ArgumentNullException(nameof(resultFactory));
            }

            self.Then(x => Task.Run(() => resultFactory(x)));
        }