コード例 #1
0
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     writer.WritePropertyName("periodType");
     writer.WriteStringValue(PeriodType.ToString());
     writer.WritePropertyName("periodValue");
     writer.WriteNumberValue(PeriodValue);
     writer.WriteEndObject();
 }
        internal static PeriodFeedbackValue DeserializePeriodFeedbackValue(JsonElement element)
        {
            PeriodType periodType  = default;
            int        periodValue = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("periodType"))
                {
                    periodType = new PeriodType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("periodValue"))
                {
                    periodValue = property.Value.GetInt32();
                    continue;
                }
            }
            return(new PeriodFeedbackValue(periodType, periodValue));
        }
コード例 #3
0
        /// <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;
        }