File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
src/Microsoft.OpenApi/Any
test/Microsoft.OpenApi.Tests/PublicApi Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,29 @@ namespace Microsoft.OpenApi.Any
10
10
/// </summary>
11
11
public class OpenApiAnyCloneHelper
12
12
{
13
+ /// <summary>
14
+ /// Clones an instance of <see cref="IOpenApiAny"/> object from the copy constructor
15
+ /// </summary>
16
+ /// <param name="obj">The object instance.</param>
17
+ /// <returns>A clone copy or the object itself.</returns>
18
+ public static IOpenApiAny CloneFromCopyConstructor ( IOpenApiAny obj )
19
+ {
20
+ if ( obj != null )
21
+ {
22
+ var t = obj . GetType ( ) ;
23
+ foreach ( var ci in t . GetConstructors ( ) )
24
+ {
25
+ var pi = ci . GetParameters ( ) ;
26
+ if ( pi . Length == 1 && pi [ 0 ] . ParameterType == t )
27
+ {
28
+ return ( IOpenApiAny ) ci . Invoke ( new object [ ] { obj } ) ;
29
+ }
30
+ }
31
+ }
32
+
33
+ return obj ;
34
+ }
35
+
13
36
/// <summary>
14
37
/// Clones an instance of <see cref="IOpenApiAny"/> object from the copy constructor
15
38
/// </summary>
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ namespace Microsoft.OpenApi.Any
22
22
public class OpenApiAnyCloneHelper
23
23
{
24
24
public OpenApiAnyCloneHelper() { }
25
+ public static Microsoft.OpenApi.Any.IOpenApiAny CloneFromCopyConstructor(Microsoft.OpenApi.Any.IOpenApiAny obj) { }
25
26
public static Microsoft.OpenApi.Any.IOpenApiAny CloneFromCopyConstructor<T>(T obj)
26
27
where T : Microsoft.OpenApi.Any.IOpenApiAny { }
27
28
}
You can’t perform that action at this time.
0 commit comments