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;
33
44using System . Reflection ;
55using System . Text ;
6+ using System ;
7+
68using Newtonsoft . Json ;
79
810public static class JsonLoader
911{
10- public static T ? resourceLoad < T > ( string _path )
12+ public static T ? resourceLoad < T > ( string path )
1113 {
12- string path = _path ;
14+ ArgumentNullException . ThrowIfNull ( path ) ;
15+
1316 path = path . Replace ( '/' , '.' ) ;
1417 path = path . Replace ( '\\ ' , '.' ) ;
1518
@@ -23,11 +26,15 @@ public static class JsonLoader
2326 . GetExecutingAssembly ( )
2427 . GetManifestResourceStream ( $ "{ path } ") ! ;
2528
26-
2729 using var streamReader = new StreamReader ( stream , Encoding . UTF8 ) ;
2830
2931 return JsonConvert . DeserializeObject < T > (
3032 streamReader . ReadToEnd ( )
3133 ) ;
3234 }
35+
36+ public static T ? stringLoad < T > ( string json )
37+ {
38+ return JsonConvert . DeserializeObject < T > ( json ) ;
39+ }
3340}
You can’t perform that action at this time.
0 commit comments