-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
RouterQueueStatistics.cs
49 lines (45 loc) · 1.81 KB
/
RouterQueueStatistics.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text.Json;
using Azure.Core;
namespace Azure.Communication.JobRouter
{
[CodeGenSerialization(nameof(EstimatedWaitTimes), SerializationValueHook = nameof(WriteEstimatedWaitTimes), DeserializationValueHook = nameof(ReadEstimatedWaitTimes))]
public partial class RouterQueueStatistics
{
/// <summary>
/// The estimated wait time of this queue rounded up to the nearest minute, grouped
/// by job priority
/// </summary>
[CodeGenMember("EstimatedWaitTimeMinutes")]
public IDictionary<int, TimeSpan> EstimatedWaitTimes { get; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void WriteEstimatedWaitTimes(Utf8JsonWriter writer)
{
writer.WriteStartObject();
foreach (var item in EstimatedWaitTimes)
{
writer.WritePropertyName(item.Key.ToString());
writer.WriteNumberValue(item.Value.TotalMinutes);
}
writer.WriteEndObject();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static void ReadEstimatedWaitTimes(JsonProperty property, ref IDictionary<int, TimeSpan> estimatedWaitTimes)
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
return;
}
var result = new Dictionary<int, TimeSpan>();
foreach (var property0 in property.Value.EnumerateObject())
{
result.Add(int.Parse(property0.Name), TimeSpan.FromMinutes(property0.Value.GetDouble()));
}
estimatedWaitTimes = result;
}
}
}