@@ -18,7 +18,9 @@ public static class MiddlewareContextMarshal
18
18
/// <param name="context">
19
19
/// The resolver context.
20
20
/// </param>
21
- /// <returns></returns>
21
+ /// <returns>
22
+ /// Returns the result data of the current resolver context.
23
+ /// </returns>
22
24
public static ObjectResult ? GetParentResultUnsafe ( IResolverContext context )
23
25
{
24
26
if ( context is null )
@@ -30,4 +32,54 @@ public static class MiddlewareContextMarshal
30
32
? middlewareContext . ParentResult
31
33
: null ;
32
34
}
35
+
36
+ /// <summary>
37
+ /// Gets the parent result data of the current <paramref name="resultData"/>.
38
+ /// </summary>
39
+ /// <param name="resultData">
40
+ /// The result data for which to get the parent.
41
+ /// </param>
42
+ /// <typeparam name="T">
43
+ /// The type of the result data.
44
+ /// </typeparam>
45
+ /// <returns>
46
+ /// Returns the parent result data of the current <paramref name="resultData"/>.
47
+ /// </returns>
48
+ /// <exception cref="ArgumentNullException">
49
+ /// Throws if <paramref name="resultData"/> is <c>null</c>.
50
+ /// </exception>
51
+ public static ResultData ? GetParent < T > ( T resultData ) where T : ResultData
52
+ {
53
+ if ( resultData == null )
54
+ {
55
+ throw new ArgumentNullException ( nameof ( resultData ) ) ;
56
+ }
57
+
58
+ return resultData . Parent ;
59
+ }
60
+
61
+ /// <summary>
62
+ /// Gets the index under which the <paramref name="resultData"/> is stored in the parent result.
63
+ /// </summary>
64
+ /// <param name="resultData">
65
+ /// The result data for which to get the parent index.
66
+ /// </param>
67
+ /// <typeparam name="T">
68
+ /// The type of the result data.
69
+ /// </typeparam>
70
+ /// <returns>
71
+ /// Returns the index under which the <paramref name="resultData"/> is stored in the parent result.
72
+ /// </returns>
73
+ /// <exception cref="ArgumentNullException">
74
+ /// Throws if <paramref name="resultData"/> is <c>null</c>.
75
+ /// </exception>
76
+ public static int GetParentIndex < T > ( T resultData ) where T : ResultData
77
+ {
78
+ if ( resultData == null )
79
+ {
80
+ throw new ArgumentNullException ( nameof ( resultData ) ) ;
81
+ }
82
+
83
+ return resultData . ParentIndex ;
84
+ }
33
85
}
0 commit comments