-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert the action/connector Data type into a dictionary of id=value …
…pairs. **This will break any plugins using the Data member directly (vs. GetValue()).** See change in sample plugin.
- Loading branch information
Showing
6 changed files
with
47 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
using TouchPortalSDK.Messages.Models; | ||
|
||
namespace TouchPortalSDK.Configuration | ||
{ | ||
internal class ActionDataConverter : JsonConverter<ActionData> | ||
{ | ||
public override ActionData Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
var ret = new ActionData(); | ||
var actionDataDicts = JsonSerializer.Deserialize<ActionData[]>(ref reader); | ||
if (actionDataDicts != null){ | ||
foreach (var dict in actionDataDicts) | ||
ret.TryAdd(dict.GetValueOrDefault("id"), dict.GetValueOrDefault("value")); | ||
} | ||
return ret; | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, ActionData value, JsonSerializerOptions options) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
| ||
namespace TouchPortalSDK.Messages.Models | ||
{ | ||
// the only real reason this is a custom type is for the JSON parser so we can write a custom handler | ||
// to break up the action data array into a dictionary. | ||
public sealed class ActionData : System.Collections.Generic.Dictionary<string, string> | ||
{ | ||
|
||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.