@@ -11,38 +11,6 @@ namespace WireMock.Util;
11
11
12
12
internal static class JsonUtils
13
13
{
14
- public static Type CreateTypeFromJObject ( JObject instance , string ? fullName = null )
15
- {
16
- static Type ConvertType ( JToken value , string ? propertyName = null )
17
- {
18
- var type = value . Type ;
19
- return type switch
20
- {
21
- JTokenType . Array => value . HasValues ? ConvertType ( value . First ! , propertyName ) . MakeArrayType ( ) : typeof ( object ) . MakeArrayType ( ) ,
22
- JTokenType . Boolean => typeof ( bool ) ,
23
- JTokenType . Bytes => typeof ( byte [ ] ) ,
24
- JTokenType . Date => typeof ( DateTime ) ,
25
- JTokenType . Guid => typeof ( Guid ) ,
26
- JTokenType . Float => typeof ( float ) ,
27
- JTokenType . Integer => typeof ( long ) ,
28
- JTokenType . Null => typeof ( object ) ,
29
- JTokenType . Object => CreateTypeFromJObject ( ( JObject ) value , propertyName ) ,
30
- JTokenType . String => typeof ( string ) ,
31
- JTokenType . TimeSpan => typeof ( TimeSpan ) ,
32
- JTokenType . Uri => typeof ( string ) ,
33
- _ => typeof ( object )
34
- } ;
35
- }
36
-
37
- var properties = new Dictionary < string , Type > ( ) ;
38
- foreach ( var item in instance . Properties ( ) )
39
- {
40
- properties . Add ( item . Name , ConvertType ( item . Value , item . Name ) ) ;
41
- }
42
-
43
- return TypeBuilderUtils . BuildType ( properties , fullName ) ?? throw new InvalidOperationException ( ) ;
44
- }
45
-
46
14
public static bool TryParseAsJObject ( string ? strInput , [ NotNullWhen ( true ) ] out JObject ? value )
47
15
{
48
16
value = null ;
@@ -141,6 +109,9 @@ public static T ParseJTokenToObject<T>(object? value)
141
109
} ;
142
110
}
143
111
112
+ /// <summary>
113
+ /// Based on / copied from Handlebars.Net Handlebars.Net.Helpers.Utils.JsonUtils
114
+ /// </summary>
144
115
public static string GenerateDynamicLinqStatement ( JToken jsonObject )
145
116
{
146
117
var lines = new List < string > ( ) ;
0 commit comments