/// <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 ServiceReplicaDescription GetFromJsonProperties(JsonReader reader)
        {
            var osType       = default(OperatingSystemType?);
            var codePackages = default(IEnumerable <ContainerCodePackageProperties>);
            var networkRefs  = default(IEnumerable <NetworkRef>);
            var diagnostics  = default(DiagnosticsRef);
            var replicaName  = default(string);

            do
            {
                var propName = reader.ReadPropertyName();
                if (string.Compare("osType", propName, StringComparison.Ordinal) == 0)
                {
                    osType = OperatingSystemTypeConverter.Deserialize(reader);
                }
                else if (string.Compare("codePackages", propName, StringComparison.Ordinal) == 0)
                {
                    codePackages = reader.ReadList(ContainerCodePackagePropertiesConverter.Deserialize);
                }
                else if (string.Compare("networkRefs", propName, StringComparison.Ordinal) == 0)
                {
                    networkRefs = reader.ReadList(NetworkRefConverter.Deserialize);
                }
                else if (string.Compare("diagnostics", propName, StringComparison.Ordinal) == 0)
                {
                    diagnostics = DiagnosticsRefConverter.Deserialize(reader);
                }
                else if (string.Compare("replicaName", propName, StringComparison.Ordinal) == 0)
                {
                    replicaName = reader.ReadValueAsString();
                }
                else
                {
                    reader.SkipPropertyValue();
                }
            }while (reader.TokenType != JsonToken.EndObject);

            return(new ServiceReplicaDescription(
                       osType: osType,
                       codePackages: codePackages,
                       networkRefs: networkRefs,
                       diagnostics: diagnostics,
                       replicaName: replicaName));
        }
        /// <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 ServiceResourceProperties GetFromJsonProperties(JsonReader reader)
        {
            var osType              = default(OperatingSystemType?);
            var codePackages        = default(IEnumerable <ContainerCodePackageProperties>);
            var networkRefs         = default(IEnumerable <NetworkRef>);
            var diagnostics         = default(DiagnosticsRef);
            var description         = default(string);
            var replicaCount        = default(int?);
            var autoScalingPolicies = default(IEnumerable <AutoScalingPolicy>);
            var status              = default(ResourceStatus?);
            var statusDetails       = default(string);
            var healthState         = default(HealthState?);
            var unhealthyEvaluation = default(string);

            do
            {
                var propName = reader.ReadPropertyName();
                if (string.Compare("osType", propName, StringComparison.Ordinal) == 0)
                {
                    osType = OperatingSystemTypeConverter.Deserialize(reader);
                }
                else if (string.Compare("codePackages", propName, StringComparison.Ordinal) == 0)
                {
                    codePackages = reader.ReadList(ContainerCodePackagePropertiesConverter.Deserialize);
                }
                else if (string.Compare("networkRefs", propName, StringComparison.Ordinal) == 0)
                {
                    networkRefs = reader.ReadList(NetworkRefConverter.Deserialize);
                }
                else if (string.Compare("diagnostics", propName, StringComparison.Ordinal) == 0)
                {
                    diagnostics = DiagnosticsRefConverter.Deserialize(reader);
                }
                else if (string.Compare("description", propName, StringComparison.Ordinal) == 0)
                {
                    description = reader.ReadValueAsString();
                }
                else if (string.Compare("replicaCount", propName, StringComparison.Ordinal) == 0)
                {
                    replicaCount = reader.ReadValueAsInt();
                }
                else if (string.Compare("autoScalingPolicies", propName, StringComparison.Ordinal) == 0)
                {
                    autoScalingPolicies = reader.ReadList(AutoScalingPolicyConverter.Deserialize);
                }
                else if (string.Compare("status", propName, StringComparison.Ordinal) == 0)
                {
                    status = ResourceStatusConverter.Deserialize(reader);
                }
                else if (string.Compare("statusDetails", propName, StringComparison.Ordinal) == 0)
                {
                    statusDetails = reader.ReadValueAsString();
                }
                else if (string.Compare("healthState", propName, StringComparison.Ordinal) == 0)
                {
                    healthState = HealthStateConverter.Deserialize(reader);
                }
                else if (string.Compare("unhealthyEvaluation", propName, StringComparison.Ordinal) == 0)
                {
                    unhealthyEvaluation = reader.ReadValueAsString();
                }
                else
                {
                    reader.SkipPropertyValue();
                }
            }while (reader.TokenType != JsonToken.EndObject);

            var serviceResourceProperties = new ServiceResourceProperties(
                osType: osType,
                codePackages: codePackages,
                networkRefs: networkRefs,
                diagnostics: diagnostics,
                description: description,
                replicaCount: replicaCount,
                autoScalingPolicies: autoScalingPolicies);

            serviceResourceProperties.Status              = status;
            serviceResourceProperties.StatusDetails       = statusDetails;
            serviceResourceProperties.HealthState         = healthState;
            serviceResourceProperties.UnhealthyEvaluation = unhealthyEvaluation;
            return(serviceResourceProperties);
        }
Esempio 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 ContainerCodePackageProperties GetFromJsonProperties(JsonReader reader)
        {
            var name  = default(string);
            var image = default(string);
            var imageRegistryCredential = default(ImageRegistryCredential);
            var entrypoint           = default(string);
            var commands             = default(IEnumerable <string>);
            var environmentVariables = default(IEnumerable <EnvironmentVariable>);
            var settings             = default(IEnumerable <Setting>);
            var labels       = default(IEnumerable <ContainerLabel>);
            var endpoints    = default(IEnumerable <EndpointProperties>);
            var resources    = default(ResourceRequirements);
            var volumeRefs   = default(IEnumerable <ContainerVolume>);
            var instanceView = default(ContainerInstanceView);
            var diagnostics  = default(DiagnosticsRef);

            do
            {
                var propName = reader.ReadPropertyName();
                if (string.Compare("name", propName, StringComparison.Ordinal) == 0)
                {
                    name = reader.ReadValueAsString();
                }
                else if (string.Compare("image", propName, StringComparison.Ordinal) == 0)
                {
                    image = reader.ReadValueAsString();
                }
                else if (string.Compare("imageRegistryCredential", propName, StringComparison.Ordinal) == 0)
                {
                    imageRegistryCredential = ImageRegistryCredentialConverter.Deserialize(reader);
                }
                else if (string.Compare("entrypoint", propName, StringComparison.Ordinal) == 0)
                {
                    entrypoint = reader.ReadValueAsString();
                }
                else if (string.Compare("commands", propName, StringComparison.Ordinal) == 0)
                {
                    commands = reader.ReadList(JsonReaderExtensions.ReadValueAsString);
                }
                else if (string.Compare("environmentVariables", propName, StringComparison.Ordinal) == 0)
                {
                    environmentVariables = reader.ReadList(EnvironmentVariableConverter.Deserialize);
                }
                else if (string.Compare("settings", propName, StringComparison.Ordinal) == 0)
                {
                    settings = reader.ReadList(SettingConverter.Deserialize);
                }
                else if (string.Compare("labels", propName, StringComparison.Ordinal) == 0)
                {
                    labels = reader.ReadList(ContainerLabelConverter.Deserialize);
                }
                else if (string.Compare("endpoints", propName, StringComparison.Ordinal) == 0)
                {
                    endpoints = reader.ReadList(EndpointPropertiesConverter.Deserialize);
                }
                else if (string.Compare("resources", propName, StringComparison.Ordinal) == 0)
                {
                    resources = ResourceRequirementsConverter.Deserialize(reader);
                }
                else if (string.Compare("volumeRefs", propName, StringComparison.Ordinal) == 0)
                {
                    volumeRefs = reader.ReadList(ContainerVolumeConverter.Deserialize);
                }
                else if (string.Compare("instanceView", propName, StringComparison.Ordinal) == 0)
                {
                    instanceView = ContainerInstanceViewConverter.Deserialize(reader);
                }
                else if (string.Compare("diagnostics", propName, StringComparison.Ordinal) == 0)
                {
                    diagnostics = DiagnosticsRefConverter.Deserialize(reader);
                }
                else
                {
                    reader.SkipPropertyValue();
                }
            }while (reader.TokenType != JsonToken.EndObject);

            return(new ContainerCodePackageProperties(
                       name: name,
                       image: image,
                       imageRegistryCredential: imageRegistryCredential,
                       entrypoint: entrypoint,
                       commands: commands,
                       environmentVariables: environmentVariables,
                       settings: settings,
                       labels: labels,
                       endpoints: endpoints,
                       resources: resources,
                       volumeRefs: volumeRefs,
                       instanceView: instanceView,
                       diagnostics: diagnostics));
        }