Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,37 @@ public static bool TryReadComplexType<T>(this ref Utf8JsonReader reader, string
return true;
}

public static bool TryReadComplexType<T>(this ref Utf8JsonReader reader, string propertyName, JsonSerializerOptions options, ref IReadOnlyDictionary<string, T>? value)
{
if (reader.TokenType != JsonTokenType.PropertyName)
{
throw new JsonException();
}

if (reader.GetString() != propertyName)
{
return false;
}

reader.Read();
if (reader.TokenType != JsonTokenType.StartObject)
{
throw new JsonException();
}
reader.Read();
var result = new Dictionary<string, T>();
while (reader.TokenType != JsonTokenType.EndObject)
{
var key = reader.GetString() ?? throw new JsonException("Dictionary key cannot be null");
reader.Read();
var item = reader.ReadWithConverter<T>(options);
result[key] = item ?? throw new JsonException();
}
reader.Read();
value = result;
return true;
}

public static T? ReadWithConverter<T>(this ref Utf8JsonReader reader, JsonSerializerOptions options)
{
var converter = (JsonConverter<T>)options.GetConverter(typeof(T));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6080,6 +6080,14 @@
"$ref": "203"
},
"value": {
"$filter": {
"$id": "2000",
"kind": "string",
"type": {
"$ref": "209"
},
"value": "status eq 'Active'"
},
"description": {
"$id": "471",
"kind": "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ static void AssertStorageTaskClientExample(InputClient client)
{ "location", "westus" },
{ "properties.description", "My Storage task" },
{ "properties.enabled", true },
{ "properties.$filter", "status eq 'Active'" },
{ "properties.action.if.condition", "[[equals(AccessTier, 'Cool')]]" },
{ "properties.action.if.operations[0].name", "SetBlobTier" },
{ "properties.action.if.operations[0].onFailure", "break" },
Expand Down
Loading