@@ -15,7 +15,28 @@ public static class PolicyBuilderExtensions
1515
1616 private static readonly ActionDescriptor EmptyActionDescriptor = new ActionDescriptor ( ) ;
1717
18- public static IResponseHandlers < TException > WithBodyActionResult < TException , TResult > (
18+ /// <summary>
19+ /// Set <see cref="IActionResult"/> to response and pass control to next handler.
20+ /// </summary>
21+ /// <typeparam name="TException">
22+ /// The exception type
23+ /// </typeparam>
24+ /// <typeparam name="TResult">
25+ /// The action result type. Should implement <see cref="IActionResult"/>.
26+ /// </typeparam>
27+ /// <param name="builder">
28+ /// The policy builder
29+ /// </param>
30+ /// <param name="resultFactory">
31+ /// The <see cref="IActionResult"/> factory.
32+ /// </param>
33+ /// <param name="index" optional="true">
34+ /// Handler index in the chain. Optional. By default handler added to the end of chain.
35+ /// </param>
36+ /// <returns>
37+ /// Policy builder
38+ /// </returns>
39+ public static IResponseHandlers < TException > WithActionResult < TException , TResult > (
1940 this IResponseHandlers < TException > builder , Func < HttpRequest , TException , TResult > resultFactory , int index = - 1 )
2041 where TException : Exception
2142 where TResult : IActionResult
@@ -38,26 +59,89 @@ public static IResponseHandlers<TException> WithBodyActionResult<TException, TRe
3859 } ) ;
3960 }
4061
41- public static IResponseHandlers < TException > WithBodyActionResult < TException , TResult > (
62+ /// <summary>
63+ /// Set <see cref="IActionResult"/> to response and pass control to next handler.
64+ /// </summary>
65+ /// <typeparam name="TException">
66+ /// The exception type
67+ /// </typeparam>
68+ /// <typeparam name="TResult">
69+ /// The action result type. Should implement <see cref="IActionResult"/>.
70+ /// </typeparam>
71+ /// <param name="builder">
72+ /// The policy builder
73+ /// </param>
74+ /// <param name="result">
75+ /// The <see cref="IActionResult"/> action result.
76+ /// </param>
77+ /// <param name="index" optional="true">
78+ /// Handler index in the chain. Optional. By default handler added to the end of chain.
79+ /// </param>
80+ /// <returns>
81+ /// Policy builder
82+ /// </returns>
83+ public static IResponseHandlers < TException > WithActionResult < TException , TResult > (
4284 this IResponseHandlers < TException > builder , TResult result , int index = - 1 )
4385 where TException : Exception
4486 where TResult : IActionResult
4587 {
46- return builder . WithBodyActionResult ( ( request , exception ) => result ) ;
88+ return builder . WithActionResult ( ( request , exception ) => result ) ;
4789 }
4890
49- public static IResponseHandlers < TException > WithBodyObjectResult < TException , TObject > (
91+ /// <summary>
92+ /// Set <see cref="ObjectResult"/> to response and pass control to next handler.
93+ /// </summary>
94+ /// <typeparam name="TException">
95+ /// The exception type
96+ /// </typeparam>
97+ /// <typeparam name="TObject">
98+ /// The result object type.
99+ /// </typeparam>
100+ /// <param name="builder">
101+ /// The policy builder
102+ /// </param>
103+ /// <param name="value">
104+ /// The result object.
105+ /// </param>
106+ /// <param name="index" optional="true">
107+ /// Handler index in the chain. Optional. By default handler added to the end of chain.
108+ /// </param>
109+ /// <returns>
110+ /// Policy builder
111+ /// </returns>
112+ public static IResponseHandlers < TException > WithObjectResult < TException , TObject > (
50113 this IResponseHandlers < TException > builder , TObject value , int index = - 1 )
51114 where TException : Exception
52115 {
53- return builder . WithBodyActionResult ( new ObjectResult ( value ) , index ) ;
116+ return builder . WithActionResult ( new ObjectResult ( value ) , index ) ;
54117 }
55118
56- public static IResponseHandlers < TException > WithBodyObjectResult < TException , TObject > (
119+ /// <summary>
120+ /// Set <see cref="ObjectResult"/> to response and pass control to next handler.
121+ /// </summary>
122+ /// <typeparam name="TException">
123+ /// The exception type
124+ /// </typeparam>
125+ /// <typeparam name="TObject">
126+ /// The result object type.
127+ /// </typeparam>
128+ /// <param name="builder">
129+ /// The policy builder
130+ /// </param>
131+ /// <param name="valueFactory">
132+ /// The result object factory.
133+ /// </param>
134+ /// <param name="index" optional="true">
135+ /// Handler index in the chain. Optional. By default handler added to the end of chain.
136+ /// </param>
137+ /// <returns>
138+ /// Policy builder
139+ /// </returns>
140+ public static IResponseHandlers < TException > WithObjectResult < TException , TObject > (
57141 this IResponseHandlers < TException > builder , Func < HttpRequest , TException , TObject > valueFactory , int index = - 1 )
58142 where TException : Exception
59143 {
60- return builder . WithBodyActionResult (
144+ return builder . WithActionResult (
61145 ( request , exception ) => new ObjectResult ( valueFactory ( request , exception ) ) , index ) ;
62146 }
63147 }
0 commit comments