/// <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 StatefulServicePartitionInfo GetFromJsonProperties(JsonReader reader)
        {
            var healthState            = default(HealthState?);
            var partitionStatus        = default(ServicePartitionStatus?);
            var partitionInformation   = default(PartitionInformation);
            var targetReplicaSetSize   = default(long?);
            var minReplicaSetSize      = default(long?);
            var lastQuorumLossDuration = default(TimeSpan?);
            var primaryEpoch           = default(Epoch);

            do
            {
                var propName = reader.ReadPropertyName();
                if (string.Compare("HealthState", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    healthState = HealthStateConverter.Deserialize(reader);
                }
                else if (string.Compare("PartitionStatus", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    partitionStatus = ServicePartitionStatusConverter.Deserialize(reader);
                }
                else if (string.Compare("PartitionInformation", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    partitionInformation = PartitionInformationConverter.Deserialize(reader);
                }
                else if (string.Compare("TargetReplicaSetSize", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    targetReplicaSetSize = reader.ReadValueAsLong();
                }
                else if (string.Compare("MinReplicaSetSize", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    minReplicaSetSize = reader.ReadValueAsLong();
                }
                else if (string.Compare("LastQuorumLossDuration", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    lastQuorumLossDuration = reader.ReadValueAsTimeSpan();
                }
                else if (string.Compare("PrimaryEpoch", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    primaryEpoch = EpochConverter.Deserialize(reader);
                }
                else
                {
                    reader.SkipPropertyValue();
                }
            }while (reader.TokenType != JsonToken.EndObject);

            return(new StatefulServicePartitionInfo(
                       healthState: healthState,
                       partitionStatus: partitionStatus,
                       partitionInformation: partitionInformation,
                       targetReplicaSetSize: targetReplicaSetSize,
                       minReplicaSetSize: minReplicaSetSize,
                       lastQuorumLossDuration: lastQuorumLossDuration,
                       primaryEpoch: primaryEpoch));
        }
Beispiel #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>
        /// <returns>The object Value.</returns>
        internal static StatelessServicePartitionInfo GetFromJsonProperties(JsonReader reader)
        {
            var healthState           = default(HealthState?);
            var partitionStatus       = default(ServicePartitionStatus?);
            var partitionInformation  = default(PartitionInformation);
            var instanceCount         = default(long?);
            var minInstanceCount      = default(int?);
            var minInstancePercentage = default(int?);

            do
            {
                var propName = reader.ReadPropertyName();
                if (string.Compare("HealthState", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    healthState = HealthStateConverter.Deserialize(reader);
                }
                else if (string.Compare("PartitionStatus", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    partitionStatus = ServicePartitionStatusConverter.Deserialize(reader);
                }
                else if (string.Compare("PartitionInformation", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    partitionInformation = PartitionInformationConverter.Deserialize(reader);
                }
                else if (string.Compare("InstanceCount", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    instanceCount = reader.ReadValueAsLong();
                }
                else if (string.Compare("MinInstanceCount", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    minInstanceCount = reader.ReadValueAsInt();
                }
                else if (string.Compare("MinInstancePercentage", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    minInstancePercentage = reader.ReadValueAsInt();
                }
                else
                {
                    reader.SkipPropertyValue();
                }
            }while (reader.TokenType != JsonToken.EndObject);

            return(new StatelessServicePartitionInfo(
                       healthState: healthState,
                       partitionStatus: partitionStatus,
                       partitionInformation: partitionInformation,
                       instanceCount: instanceCount,
                       minInstanceCount: minInstanceCount,
                       minInstancePercentage: minInstancePercentage));
        }