mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-04-12 20:16:34 +00:00
fix: resolve StringReader compatibility between .NET Framework and .NET 6
- Add conditional compilation directives to use appropriate StringReader implementation - Use System.IO.StringReader for .NET 6 - Use Crestron.SimplSharp.CrestronIO.StringReader for .NET Framework
This commit is contained in:
parent
1fd355d808
commit
d03e136ada
1 changed files with 12 additions and 3 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharp.CrestronIO;
|
||||
using Newtonsoft.Json;
|
||||
|
|
@ -159,7 +160,11 @@ namespace PepperDash.Core.JsonToSimpl
|
|||
/// <returns></returns>
|
||||
public static JObject ParseObject(string json)
|
||||
{
|
||||
using (var reader = new JsonTextReader(new StringReader(json)))
|
||||
#if NET6_0
|
||||
using (var reader = new JsonTextReader(new System.IO.StringReader(json)))
|
||||
#else
|
||||
using (var reader = new JsonTextReader(new Crestron.SimplSharp.CrestronIO.StringReader(json)))
|
||||
#endif
|
||||
{
|
||||
var startDepth = reader.Depth;
|
||||
var obj = JObject.Load(reader);
|
||||
|
|
@ -176,7 +181,11 @@ namespace PepperDash.Core.JsonToSimpl
|
|||
/// <returns></returns>
|
||||
public static JArray ParseArray(string json)
|
||||
{
|
||||
using (var reader = new JsonTextReader(new StringReader(json)))
|
||||
#if NET6_0
|
||||
using (var reader = new JsonTextReader(new System.IO.StringReader(json)))
|
||||
#else
|
||||
using (var reader = new JsonTextReader(new Crestron.SimplSharp.CrestronIO.StringReader(json)))
|
||||
#endif
|
||||
{
|
||||
var startDepth = reader.Depth;
|
||||
var obj = JArray.Load(reader);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue