Skip to content

Commit

Permalink
Deserialize custom dimensions from application insights API response.
Browse files Browse the repository at this point in the history
  • Loading branch information
olegd-superoffice committed Aug 13, 2020
1 parent 3b2cc9e commit ec492e8
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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<string, JToken> _customDimensionsValues;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value

public IEnumerable<string> 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;
}
}
}

0 comments on commit ec492e8

Please sign in to comment.