-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change WPS ConnectionContext.States to a Dict<string, BinaryData> (#2…
…5504) This looks more like the rest of Track 2 and also removes the `TryGetState<T>` method because BinaryData already has https://docs.microsoft.com/en-us/dotnet/api/system.binarydata.toobjectfromjson?view=dotnet-plat-ext-6.0#System_BinaryData_ToObjectFromJson__1_System_Text_Json_JsonSerializerOptions_.
- Loading branch information
Showing
34 changed files
with
888 additions
and
305 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
10 changes: 4 additions & 6 deletions
10
sdk/webpubsub/Microsoft.Azure.WebJobs.Extensions.WebPubSub/CHANGELOG.md
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
42 changes: 42 additions & 0 deletions
42
...ft.Azure.WebJobs.Extensions.WebPubSub/src/Bindings/ConnectionStatesNewtonsoftConverter.cs
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,42 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace Microsoft.Azure.WebJobs.Extensions.WebPubSub | ||
{ | ||
/// <summary> | ||
/// JsonConverter works for Functions JavaScript language object converters. | ||
/// </summary> | ||
internal class ConnectionStatesNewtonsoftConverter : JsonConverter<IReadOnlyDictionary<string, BinaryData>> | ||
{ | ||
public override IReadOnlyDictionary<string, BinaryData> ReadJson(JsonReader reader, Type objectType, IReadOnlyDictionary<string, BinaryData> existingValue, bool hasExistingValue, JsonSerializer serializer) | ||
{ | ||
var dict = new Dictionary<string, BinaryData>(); | ||
var jDict = JToken.Load(reader).ToObject<Dictionary<string, JToken>>(); | ||
foreach (var item in jDict) | ||
{ | ||
dict.Add(item.Key, BinaryData.FromString(JsonConvert.SerializeObject(item.Value))); | ||
} | ||
|
||
return dict; | ||
} | ||
|
||
public override void WriteJson(JsonWriter writer, IReadOnlyDictionary<string, BinaryData> value, JsonSerializer serializer) | ||
{ | ||
writer.WriteStartObject(); | ||
if (value != null) | ||
{ | ||
foreach (KeyValuePair<string, BinaryData> pair in value) | ||
{ | ||
writer.WritePropertyName(pair.Key); | ||
writer.WriteRawValue(pair.Value.ToString()); | ||
} | ||
} | ||
writer.WriteEndObject(); | ||
} | ||
} | ||
} |
26 changes: 0 additions & 26 deletions
26
...sub/Microsoft.Azure.WebJobs.Extensions.WebPubSub/src/Bindings/JsonElementJsonConverter.cs
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.