internal static MetricPeriodFeedback DeserializeMetricPeriodFeedback(JsonElement element) { Optional <PeriodFeedbackValue> value = default; FeedbackType feedbackType = default; Optional <string> feedbackId = default; Optional <DateTimeOffset> createdTime = default; Optional <string> userPrincipal = default; string metricId = default; FeedbackDimensionFilter dimensionFilter = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } value = PeriodFeedbackValue.DeserializePeriodFeedbackValue(property.Value); continue; } if (property.NameEquals("feedbackType")) { feedbackType = new FeedbackType(property.Value.GetString()); continue; } if (property.NameEquals("feedbackId")) { feedbackId = property.Value.GetString(); continue; } if (property.NameEquals("createdTime")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } createdTime = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("userPrincipal")) { userPrincipal = property.Value.GetString(); continue; } if (property.NameEquals("metricId")) { metricId = property.Value.GetString(); continue; } if (property.NameEquals("dimensionFilter")) { dimensionFilter = FeedbackDimensionFilter.DeserializeFeedbackDimensionFilter(property.Value); continue; } } return(new MetricPeriodFeedback(feedbackType, feedbackId.Value, Optional.ToNullable(createdTime), userPrincipal.Value, metricId, dimensionFilter, value.Value)); }
/// <summary> Initializes a new <see cref="MetricPeriodFeedback"/> instance. </summary> /// <param name="metricId"> The metric unique id. </param> /// <param name="dimensionFilter"> The <see cref="FeedbackDimensionFilter"/> to apply to the feedback. </param> /// <param name="periodType"> The <see cref="Models.PeriodType"/>. </param> /// <param name="periodValue"> The period value. </param> /// <exception cref="ArgumentNullException"> <paramref name="metricId"/> or <paramref name="dimensionFilter"/> is null. </exception> /// <exception cref="ArgumentException"> <paramref name="metricId"/> is empty. </exception> public MetricPeriodFeedback(string metricId, FeedbackDimensionFilter dimensionFilter, PeriodType periodType, int periodValue) : base(metricId, dimensionFilter) { Argument.AssertNotNullOrEmpty(metricId, nameof(metricId)); Argument.AssertNotNull(dimensionFilter, nameof(dimensionFilter)); ValueInternal = new PeriodFeedbackValue(periodType, periodValue); Type = FeedbackType.Period; }
/// <summary> /// Initializes a new instance of <see cref="MetricsAdvisor.MetricPeriodFeedback"/> for mocking purposes. /// </summary> /// <param name="id">Sets the <see cref="MetricFeedback.Id"/> property.</param> /// <param name="createdOn">Sets the <see cref="MetricFeedback.CreatedOn"/> property.</param> /// <param name="userPrincipal">Sets the <see cref="MetricFeedback.UserPrincipal"/> property.</param> /// <param name="metricId">Sets the <see cref="MetricFeedback.MetricId"/> property.</param> /// <param name="dimensionKey">Sets the <see cref="MetricFeedback.DimensionKey"/> property.</param> /// <param name="periodType">Sets the <see cref="MetricPeriodFeedback.PeriodType"/> property.</param> /// <param name="periodValue">Sets the <see cref="MetricPeriodFeedback.PeriodValue"/> property.</param> /// <returns>A new instance of <see cref="MetricsAdvisor.MetricPeriodFeedback"/> for mocking purposes.</returns> public static MetricPeriodFeedback MetricPeriodFeedback(string id = null, DateTimeOffset?createdOn = null, string userPrincipal = null, string metricId = null, DimensionKey dimensionKey = null, MetricPeriodType periodType = default, int periodValue = default) { Dictionary <string, string> dimensions = dimensionKey?.ToDictionary(key => key.Key, key => key.Value); FeedbackFilter filter = new FeedbackFilter(dimensions); PeriodFeedbackValue feedbackValue = new PeriodFeedbackValue(periodType, periodValue); return(new MetricPeriodFeedback(MetricFeedbackKind.Period, id, createdOn, userPrincipal, metricId, filter, feedbackValue)); }
/// <summary> Initializes a new <see cref="MetricPeriodFeedback"/> instance. </summary> /// <param name="metricId"> The metric unique id. </param> /// <param name="dimensionFilter"> The <see cref="FeedbackDimensionFilter"/> to apply to the feedback. </param> /// <param name="value"> The <see cref="PeriodFeedbackValue"/> for the feedback. </param> /// <exception cref="ArgumentNullException"> <paramref name="metricId"/>, <paramref name="dimensionFilter"/>, or <paramref name="value"/> is null. </exception> /// <exception cref="ArgumentException"> <paramref name="metricId"/> is empty. </exception> public MetricPeriodFeedback(string metricId, FeedbackDimensionFilter dimensionFilter, PeriodFeedbackValue value) : base(metricId, dimensionFilter) { Argument.AssertNotNullOrEmpty(metricId, nameof(metricId)); Argument.AssertNotNull(dimensionFilter, nameof(dimensionFilter)); Argument.AssertNotNull(value, nameof(value)); ValueInternal = value; Type = FeedbackType.Period; }
public PeriodFeedback(Guid metricId, FeedbackDimensionFilter dimensionFilter, PeriodFeedbackValue value) : base(metricId, dimensionFilter) { if (dimensionFilter == null) { throw new ArgumentNullException(nameof(dimensionFilter)); } if (value == null) { throw new ArgumentNullException(nameof(value)); } Value = value; FeedbackType = Models.FeedbackType.Period; }
internal static PeriodFeedback DeserializePeriodFeedback(JsonElement element) { PeriodFeedbackValue value = default; FeedbackType feedbackType = default; Optional <Guid> feedbackId = default; Optional <DateTimeOffset> createdTime = default; Optional <string> userPrincipal = default; Guid metricId = default; FeedbackDimensionFilter dimensionFilter = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value")) { value = PeriodFeedbackValue.DeserializePeriodFeedbackValue(property.Value); continue; } if (property.NameEquals("feedbackType")) { feedbackType = new FeedbackType(property.Value.GetString()); continue; } if (property.NameEquals("feedbackId")) { feedbackId = property.Value.GetGuid(); continue; } if (property.NameEquals("createdTime")) { createdTime = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("userPrincipal")) { userPrincipal = property.Value.GetString(); continue; } if (property.NameEquals("metricId")) { metricId = property.Value.GetGuid(); continue; } if (property.NameEquals("dimensionFilter")) { dimensionFilter = FeedbackDimensionFilter.DeserializeFeedbackDimensionFilter(property.Value); continue; } } return(new PeriodFeedback(feedbackType, Optional.ToNullable(feedbackId), Optional.ToNullable(createdTime), userPrincipal.Value, metricId, dimensionFilter, value)); }
/// <summary> Initializes a new instance of MetricPeriodFeedback. </summary> /// <param name="metricId"> metric unique id. </param> /// <param name="dimensionFilter"> . </param> /// <param name="valueInternal"> . </param> /// <exception cref="ArgumentNullException"> <paramref name="metricId"/>, <paramref name="dimensionFilter"/>, or <paramref name="valueInternal"/> is null. </exception> internal MetricPeriodFeedback(string metricId, FeedbackDimensionFilter dimensionFilter, PeriodFeedbackValue valueInternal) : base(metricId, dimensionFilter) { if (metricId == null) { throw new ArgumentNullException(nameof(metricId)); } if (dimensionFilter == null) { throw new ArgumentNullException(nameof(dimensionFilter)); } if (valueInternal == null) { throw new ArgumentNullException(nameof(valueInternal)); } ValueInternal = valueInternal; Type = FeedbackType.Period; }
internal PeriodFeedback(FeedbackType feedbackType, Guid?feedbackId, DateTimeOffset?createdTime, string userPrincipal, Guid metricId, FeedbackDimensionFilter dimensionFilter, PeriodFeedbackValue value) : base(feedbackType, feedbackId, createdTime, userPrincipal, metricId, dimensionFilter) { Value = value; FeedbackType = feedbackType; }
internal MetricPeriodFeedback(FeedbackType type, string id, DateTimeOffset?createdTime, string userPrincipal, string metricId, FeedbackDimensionFilter dimensionFilter, PeriodFeedbackValue valueInternal) : base(type, id, createdTime, userPrincipal, metricId, dimensionFilter) { ValueInternal = valueInternal; Type = type; }