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 StatefulServiceUpdateDescription GetFromJsonProperties(JsonReader reader)
        {
            var flags = default(string);
            var placementConstraints              = default(string);
            var correlationScheme                 = default(IEnumerable <ServiceCorrelationDescription>);
            var loadMetrics                       = default(IEnumerable <ServiceLoadMetricDescription>);
            var servicePlacementPolicies          = default(IEnumerable <ServicePlacementPolicyDescription>);
            var defaultMoveCost                   = default(MoveCost?);
            var scalingPolicies                   = default(IEnumerable <ScalingPolicyDescription>);
            var serviceDnsName                    = default(string);
            var tagsForPlacement                  = default(NodeTagsDescription);
            var tagsForRunning                    = default(NodeTagsDescription);
            var targetReplicaSetSize              = default(int?);
            var minReplicaSetSize                 = default(int?);
            var replicaRestartWaitDurationSeconds = default(string);
            var quorumLossWaitDurationSeconds     = default(string);
            var standByReplicaKeepDurationSeconds = default(string);
            var servicePlacementTimeLimitSeconds  = default(string);
            var dropSourceReplicaOnMove           = default(bool?);
            var replicaLifecycleDescription       = default(ReplicaLifecycleDescription);
            var auxiliaryReplicaCount             = default(int?);

            do
            {
                var propName = reader.ReadPropertyName();
                if (string.Compare("Flags", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    flags = reader.ReadValueAsString();
                }
                else if (string.Compare("PlacementConstraints", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    placementConstraints = reader.ReadValueAsString();
                }
                else if (string.Compare("CorrelationScheme", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    correlationScheme = reader.ReadList(ServiceCorrelationDescriptionConverter.Deserialize);
                }
                else if (string.Compare("LoadMetrics", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    loadMetrics = reader.ReadList(ServiceLoadMetricDescriptionConverter.Deserialize);
                }
                else if (string.Compare("ServicePlacementPolicies", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    servicePlacementPolicies = reader.ReadList(ServicePlacementPolicyDescriptionConverter.Deserialize);
                }
                else if (string.Compare("DefaultMoveCost", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    defaultMoveCost = MoveCostConverter.Deserialize(reader);
                }
                else if (string.Compare("ScalingPolicies", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    scalingPolicies = reader.ReadList(ScalingPolicyDescriptionConverter.Deserialize);
                }
                else if (string.Compare("ServiceDnsName", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    serviceDnsName = reader.ReadValueAsString();
                }
                else if (string.Compare("TagsForPlacement", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    tagsForPlacement = NodeTagsDescriptionConverter.Deserialize(reader);
                }
                else if (string.Compare("TagsForRunning", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    tagsForRunning = NodeTagsDescriptionConverter.Deserialize(reader);
                }
                else if (string.Compare("TargetReplicaSetSize", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    targetReplicaSetSize = reader.ReadValueAsInt();
                }
                else if (string.Compare("MinReplicaSetSize", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    minReplicaSetSize = reader.ReadValueAsInt();
                }
                else if (string.Compare("ReplicaRestartWaitDurationSeconds", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    replicaRestartWaitDurationSeconds = reader.ReadValueAsString();
                }
                else if (string.Compare("QuorumLossWaitDurationSeconds", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    quorumLossWaitDurationSeconds = reader.ReadValueAsString();
                }
                else if (string.Compare("StandByReplicaKeepDurationSeconds", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    standByReplicaKeepDurationSeconds = reader.ReadValueAsString();
                }
                else if (string.Compare("ServicePlacementTimeLimitSeconds", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    servicePlacementTimeLimitSeconds = reader.ReadValueAsString();
                }
                else if (string.Compare("DropSourceReplicaOnMove", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    dropSourceReplicaOnMove = reader.ReadValueAsBool();
                }
                else if (string.Compare("ReplicaLifecycleDescription", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    replicaLifecycleDescription = ReplicaLifecycleDescriptionConverter.Deserialize(reader);
                }
                else if (string.Compare("AuxiliaryReplicaCount", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    auxiliaryReplicaCount = reader.ReadValueAsInt();
                }
                else
                {
                    reader.SkipPropertyValue();
                }
            }while (reader.TokenType != JsonToken.EndObject);

            return(new StatefulServiceUpdateDescription(
                       flags: flags,
                       placementConstraints: placementConstraints,
                       correlationScheme: correlationScheme,
                       loadMetrics: loadMetrics,
                       servicePlacementPolicies: servicePlacementPolicies,
                       defaultMoveCost: defaultMoveCost,
                       scalingPolicies: scalingPolicies,
                       serviceDnsName: serviceDnsName,
                       tagsForPlacement: tagsForPlacement,
                       tagsForRunning: tagsForRunning,
                       targetReplicaSetSize: targetReplicaSetSize,
                       minReplicaSetSize: minReplicaSetSize,
                       replicaRestartWaitDurationSeconds: replicaRestartWaitDurationSeconds,
                       quorumLossWaitDurationSeconds: quorumLossWaitDurationSeconds,
                       standByReplicaKeepDurationSeconds: standByReplicaKeepDurationSeconds,
                       servicePlacementTimeLimitSeconds: servicePlacementTimeLimitSeconds,
                       dropSourceReplicaOnMove: dropSourceReplicaOnMove,
                       replicaLifecycleDescription: replicaLifecycleDescription,
                       auxiliaryReplicaCount: auxiliaryReplicaCount));
        }
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>
        /// <returns>The object Value.</returns>
        internal static StatefulServiceDescription GetFromJsonProperties(JsonReader reader)
        {
            var applicationName              = default(ApplicationName);
            var serviceName                  = default(ServiceName);
            var serviceTypeName              = default(string);
            var initializationData           = default(byte[]);
            var partitionDescription         = default(PartitionSchemeDescription);
            var placementConstraints         = default(string);
            var correlationScheme            = default(IEnumerable <ServiceCorrelationDescription>);
            var serviceLoadMetrics           = default(IEnumerable <ServiceLoadMetricDescription>);
            var servicePlacementPolicies     = default(IEnumerable <ServicePlacementPolicyDescription>);
            var defaultMoveCost              = default(MoveCost?);
            var isDefaultMoveCostSpecified   = default(bool?);
            var servicePackageActivationMode = default(ServicePackageActivationMode?);
            var serviceDnsName               = default(string);
            var scalingPolicies              = default(IEnumerable <ScalingPolicyDescription>);
            var tagsRequiredToPlace          = default(NodeTagsDescription);
            var tagsRequiredToRun            = default(NodeTagsDescription);
            var targetReplicaSetSize         = default(int?);
            var minReplicaSetSize            = default(int?);
            var hasPersistedState            = default(bool?);
            var flags = default(int?);
            var replicaRestartWaitDurationSeconds = default(long?);
            var quorumLossWaitDurationSeconds     = default(long?);
            var standByReplicaKeepDurationSeconds = default(long?);
            var servicePlacementTimeLimitSeconds  = default(long?);
            var dropSourceReplicaOnMove           = default(bool?);
            var replicaLifecycleDescription       = default(ReplicaLifecycleDescription);
            var auxiliaryReplicaCount             = default(int?);

            do
            {
                var propName = reader.ReadPropertyName();
                if (string.Compare("ApplicationName", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    applicationName = ApplicationNameConverter.Deserialize(reader);
                }
                else if (string.Compare("ServiceName", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    serviceName = ServiceNameConverter.Deserialize(reader);
                }
                else if (string.Compare("ServiceTypeName", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    serviceTypeName = reader.ReadValueAsString();
                }
                else if (string.Compare("InitializationData", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    initializationData = ByteArrayConverter.Deserialize(reader);
                }
                else if (string.Compare("PartitionDescription", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    partitionDescription = PartitionSchemeDescriptionConverter.Deserialize(reader);
                }
                else if (string.Compare("PlacementConstraints", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    placementConstraints = reader.ReadValueAsString();
                }
                else if (string.Compare("CorrelationScheme", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    correlationScheme = reader.ReadList(ServiceCorrelationDescriptionConverter.Deserialize);
                }
                else if (string.Compare("ServiceLoadMetrics", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    serviceLoadMetrics = reader.ReadList(ServiceLoadMetricDescriptionConverter.Deserialize);
                }
                else if (string.Compare("ServicePlacementPolicies", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    servicePlacementPolicies = reader.ReadList(ServicePlacementPolicyDescriptionConverter.Deserialize);
                }
                else if (string.Compare("DefaultMoveCost", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    defaultMoveCost = MoveCostConverter.Deserialize(reader);
                }
                else if (string.Compare("IsDefaultMoveCostSpecified", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    isDefaultMoveCostSpecified = reader.ReadValueAsBool();
                }
                else if (string.Compare("ServicePackageActivationMode", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    servicePackageActivationMode = ServicePackageActivationModeConverter.Deserialize(reader);
                }
                else if (string.Compare("ServiceDnsName", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    serviceDnsName = reader.ReadValueAsString();
                }
                else if (string.Compare("ScalingPolicies", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    scalingPolicies = reader.ReadList(ScalingPolicyDescriptionConverter.Deserialize);
                }
                else if (string.Compare("TagsRequiredToPlace", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    tagsRequiredToPlace = NodeTagsDescriptionConverter.Deserialize(reader);
                }
                else if (string.Compare("TagsRequiredToRun", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    tagsRequiredToRun = NodeTagsDescriptionConverter.Deserialize(reader);
                }
                else if (string.Compare("TargetReplicaSetSize", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    targetReplicaSetSize = reader.ReadValueAsInt();
                }
                else if (string.Compare("MinReplicaSetSize", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    minReplicaSetSize = reader.ReadValueAsInt();
                }
                else if (string.Compare("HasPersistedState", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    hasPersistedState = reader.ReadValueAsBool();
                }
                else if (string.Compare("Flags", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    flags = reader.ReadValueAsInt();
                }
                else if (string.Compare("ReplicaRestartWaitDurationSeconds", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    replicaRestartWaitDurationSeconds = reader.ReadValueAsLong();
                }
                else if (string.Compare("QuorumLossWaitDurationSeconds", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    quorumLossWaitDurationSeconds = reader.ReadValueAsLong();
                }
                else if (string.Compare("StandByReplicaKeepDurationSeconds", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    standByReplicaKeepDurationSeconds = reader.ReadValueAsLong();
                }
                else if (string.Compare("ServicePlacementTimeLimitSeconds", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    servicePlacementTimeLimitSeconds = reader.ReadValueAsLong();
                }
                else if (string.Compare("DropSourceReplicaOnMove", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    dropSourceReplicaOnMove = reader.ReadValueAsBool();
                }
                else if (string.Compare("ReplicaLifecycleDescription", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    replicaLifecycleDescription = ReplicaLifecycleDescriptionConverter.Deserialize(reader);
                }
                else if (string.Compare("AuxiliaryReplicaCount", propName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    auxiliaryReplicaCount = reader.ReadValueAsInt();
                }
                else
                {
                    reader.SkipPropertyValue();
                }
            }while (reader.TokenType != JsonToken.EndObject);

            return(new StatefulServiceDescription(
                       applicationName: applicationName,
                       serviceName: serviceName,
                       serviceTypeName: serviceTypeName,
                       initializationData: initializationData,
                       partitionDescription: partitionDescription,
                       placementConstraints: placementConstraints,
                       correlationScheme: correlationScheme,
                       serviceLoadMetrics: serviceLoadMetrics,
                       servicePlacementPolicies: servicePlacementPolicies,
                       defaultMoveCost: defaultMoveCost,
                       isDefaultMoveCostSpecified: isDefaultMoveCostSpecified,
                       servicePackageActivationMode: servicePackageActivationMode,
                       serviceDnsName: serviceDnsName,
                       scalingPolicies: scalingPolicies,
                       tagsRequiredToPlace: tagsRequiredToPlace,
                       tagsRequiredToRun: tagsRequiredToRun,
                       targetReplicaSetSize: targetReplicaSetSize,
                       minReplicaSetSize: minReplicaSetSize,
                       hasPersistedState: hasPersistedState,
                       flags: flags,
                       replicaRestartWaitDurationSeconds: replicaRestartWaitDurationSeconds,
                       quorumLossWaitDurationSeconds: quorumLossWaitDurationSeconds,
                       standByReplicaKeepDurationSeconds: standByReplicaKeepDurationSeconds,
                       servicePlacementTimeLimitSeconds: servicePlacementTimeLimitSeconds,
                       dropSourceReplicaOnMove: dropSourceReplicaOnMove,
                       replicaLifecycleDescription: replicaLifecycleDescription,
                       auxiliaryReplicaCount: auxiliaryReplicaCount));
        }