Ejemplo n.º 1
0
        /// <summary>
        /// Gets the object from Json properties.
        /// </summary>
        /// <param name="reader">The <see cref="T: Newtonsoft.Json.JsonReader" /> to read from, reader must be placed at first property.</param>
        /// <returns>The object Value.</returns>
        internal static ChaosEventsSegment GetFromJsonProperties(JsonReader reader)
        {
            var continuationToken = default(ContinuationToken);
            var history           = default(IEnumerable <ChaosEventWrapper>);

            do
            {
                var propName = reader.ReadPropertyName();
                if (string.Compare("ContinuationToken", propName, StringComparison.Ordinal) == 0)
                {
                    continuationToken = ContinuationTokenConverter.Deserialize(reader);
                }
                else if (string.Compare("History", propName, StringComparison.Ordinal) == 0)
                {
                    history = reader.ReadList(ChaosEventWrapperConverter.Deserialize);
                }
                else
                {
                    reader.SkipPropertyValue();
                }
            }while (reader.TokenType != JsonToken.EndObject);

            return(new ChaosEventsSegment(
                       continuationToken: continuationToken,
                       history: history));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the object from Json properties.
        /// </summary>
        /// <param name="reader">The <see cref="T: Newtonsoft.Json.JsonReader" /> to read from, reader must be placed at first property.</param>
        /// <param name="deserializeFunc">Deserializer Func for T.</param>
        /// <returns>The object Value.</returns>
        public static PagedData <T> GetFromJsonProperties(JsonReader reader, Func <JsonReader, T> deserializeFunc)
        {
            var continuationToken = default(ContinuationToken);
            var items             = default(IList <T>);

            do
            {
                var propName = reader.ReadPropertyName();
                if (string.Compare("ContinuationToken", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    continuationToken = ContinuationTokenConverter.Deserialize(reader);
                }
                else if (string.Compare("Items", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    items = reader.ReadList(deserializeFunc);
                }
                else if (string.Compare("History", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    items = reader.ReadList(deserializeFunc);
                }
                else if (string.Compare("Properties", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    items = reader.ReadList(deserializeFunc);
                }
                else
                {
                    reader.SkipPropertyValue();
                }
            }while (reader.TokenType != JsonToken.EndObject);

            return(new PagedData <T>(continuationToken, items));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the object from Json properties.
        /// </summary>
        /// <param name="reader">The <see cref="T: Newtonsoft.Json.JsonReader" /> to read from, reader must be placed at first property.</param>
        /// <returns>The object Value.</returns>
        internal static LoadedPartitionInformationQueryDescription GetFromJsonProperties(JsonReader reader)
        {
            var metricName        = default(string);
            var serviceName       = default(string);
            var ordering          = default(Ordering?);
            var maxResults        = default(long?);
            var continuationToken = default(ContinuationToken);

            do
            {
                var propName = reader.ReadPropertyName();
                if (string.Compare("MetricName", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    metricName = reader.ReadValueAsString();
                }
                else if (string.Compare("ServiceName", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    serviceName = reader.ReadValueAsString();
                }
                else if (string.Compare("Ordering", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    ordering = OrderingConverter.Deserialize(reader);
                }
                else if (string.Compare("MaxResults", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    maxResults = reader.ReadValueAsLong();
                }
                else if (string.Compare("ContinuationToken", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    continuationToken = ContinuationTokenConverter.Deserialize(reader);
                }
                else
                {
                    reader.SkipPropertyValue();
                }
            }while (reader.TokenType != JsonToken.EndObject);

            return(new LoadedPartitionInformationQueryDescription(
                       metricName: metricName,
                       serviceName: serviceName,
                       ordering: ordering,
                       maxResults: maxResults,
                       continuationToken: continuationToken));
        }