From ec492e8666f8577c37943fcc20197dc72fa7bb49 Mon Sep 17 00:00:00 2001 From: Oleg Deribas Date: Fri, 26 Jun 2020 15:57:29 +0200 Subject: [PATCH] Deserialize custom dimensions from application insights API response. Fixes #13042 --- .../EventsResultDataCustomDimensions.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 sdk/applicationinsights/Microsoft.Azure.ApplicationInsights.Query/src/Customized/Models/EventsResultDataCustomDimensions.cs diff --git a/sdk/applicationinsights/Microsoft.Azure.ApplicationInsights.Query/src/Customized/Models/EventsResultDataCustomDimensions.cs b/sdk/applicationinsights/Microsoft.Azure.ApplicationInsights.Query/src/Customized/Models/EventsResultDataCustomDimensions.cs new file mode 100644 index 000000000000..efbbbe644634 --- /dev/null +++ b/sdk/applicationinsights/Microsoft.Azure.ApplicationInsights.Query/src/Customized/Models/EventsResultDataCustomDimensions.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Azure.ApplicationInsights.Query.Models +{ + public partial class EventsResultDataCustomDimensions + { +#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value + [JsonExtensionData] + private IDictionary _customDimensionsValues; +#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value + + public IEnumerable Keys => _customDimensionsValues?.Keys; + + public bool TryGetValue(string key, out string value) + { + if (_customDimensionsValues != null && _customDimensionsValues.TryGetValue(key, out var jToken)) + { + value = jToken?.ToString(); + return true; + } + value = null; + return false; + } + } +}