File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
src/algorithm_exercises_csharp_test/lib Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -3,13 +3,16 @@ namespace algorithm_exercises_csharp_test.lib;
3
3
4
4
using System . Reflection ;
5
5
using System . Text ;
6
+ using System ;
7
+
6
8
using Newtonsoft . Json ;
7
9
8
10
public static class JsonLoader
9
11
{
10
- public static T ? resourceLoad < T > ( string _path )
12
+ public static T ? resourceLoad < T > ( string path )
11
13
{
12
- string path = _path ;
14
+ ArgumentNullException . ThrowIfNull ( path ) ;
15
+
13
16
path = path . Replace ( '/' , '.' ) ;
14
17
path = path . Replace ( '\\ ' , '.' ) ;
15
18
@@ -23,11 +26,15 @@ public static class JsonLoader
23
26
. GetExecutingAssembly ( )
24
27
. GetManifestResourceStream ( $ "{ path } ") ! ;
25
28
26
-
27
29
using var streamReader = new StreamReader ( stream , Encoding . UTF8 ) ;
28
30
29
31
return JsonConvert . DeserializeObject < T > (
30
32
streamReader . ReadToEnd ( )
31
33
) ;
32
34
}
35
+
36
+ public static T ? stringLoad < T > ( string json )
37
+ {
38
+ return JsonConvert . DeserializeObject < T > ( json ) ;
39
+ }
33
40
}
You can’t perform that action at this time.
0 commit comments