More improvements to TestHelper.GetStringVal

pull/211/head
dahall 2021-01-24 18:59:36 -07:00
parent adf48e9d4f
commit 0a1609d06a
1 changed files with 7 additions and 1 deletions

View File

@ -15,6 +15,12 @@ namespace Vanara.PInvoke.Tests
{
private const string testApp = @"C:\Users\dahall\Documents\Visual Studio 2017\Projects\TestSysConsumption\bin\Debug\netcoreapp3.0\TestSysConsumption.exe";
private static Lazy<JsonSerializerSettings> jsonSet = new Lazy<JsonSerializerSettings>(() =>
new JsonSerializerSettings() {
Converters = new JsonConverter[] { new Newtonsoft.Json.Converters.StringEnumConverter(), new SizeTConverter() },
ReferenceLoopHandling = ReferenceLoopHandling.Serialize
});
public static Process RunThrottleApp() => Process.Start(testApp);
public static void SetThrottle(string type, bool on)
@ -94,7 +100,7 @@ namespace Vanara.PInvoke.Tests
return mem.Dump;
default:
try { return JsonConvert.SerializeObject(value, Formatting.Indented, new Newtonsoft.Json.Converters.StringEnumConverter(), new SizeTConverter()); }
try { return JsonConvert.SerializeObject(value, Formatting.Indented, jsonSet.Value); }
catch (Exception e) { return e.ToString(); }
}
}