示例#1
0
 internal CloudServiceProperties(Uri packageUri, string configuration, Uri configurationUri, bool?startCloudService, bool?allowModelOverride, CloudServiceUpgradeMode?upgradeMode, CloudServiceRoleProfile roleProfile, CloudServiceOSProfile osProfile, CloudServiceNetworkProfile networkProfile, CloudServiceExtensionProfile extensionProfile, string provisioningState, string uniqueId)
 {
     PackageUri         = packageUri;
     Configuration      = configuration;
     ConfigurationUri   = configurationUri;
     StartCloudService  = startCloudService;
     AllowModelOverride = allowModelOverride;
     UpgradeMode        = upgradeMode;
     RoleProfile        = roleProfile;
     OSProfile          = osProfile;
     NetworkProfile     = networkProfile;
     ExtensionProfile   = extensionProfile;
     ProvisioningState  = provisioningState;
     UniqueId           = uniqueId;
 }
示例#2
0
        internal static CloudServiceProperties DeserializeCloudServiceProperties(JsonElement element)
        {
            Optional <string> packageUrl         = default;
            Optional <string> configuration      = default;
            Optional <string> configurationUrl   = default;
            Optional <bool>   startCloudService  = default;
            Optional <bool>   allowModelOverride = default;
            Optional <CloudServiceUpgradeMode>      upgradeMode      = default;
            Optional <CloudServiceRoleProfile>      roleProfile      = default;
            Optional <CloudServiceOSProfile>        osProfile        = default;
            Optional <CloudServiceNetworkProfile>   networkProfile   = default;
            Optional <CloudServiceExtensionProfile> extensionProfile = default;
            Optional <string> provisioningState = default;
            Optional <string> uniqueId          = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("packageUrl"))
                {
                    packageUrl = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("configuration"))
                {
                    configuration = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("configurationUrl"))
                {
                    configurationUrl = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("startCloudService"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    startCloudService = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("allowModelOverride"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    allowModelOverride = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("upgradeMode"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    upgradeMode = new CloudServiceUpgradeMode(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("roleProfile"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    roleProfile = CloudServiceRoleProfile.DeserializeCloudServiceRoleProfile(property.Value);
                    continue;
                }
                if (property.NameEquals("osProfile"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    osProfile = CloudServiceOSProfile.DeserializeCloudServiceOSProfile(property.Value);
                    continue;
                }
                if (property.NameEquals("networkProfile"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    networkProfile = CloudServiceNetworkProfile.DeserializeCloudServiceNetworkProfile(property.Value);
                    continue;
                }
                if (property.NameEquals("extensionProfile"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    extensionProfile = CloudServiceExtensionProfile.DeserializeCloudServiceExtensionProfile(property.Value);
                    continue;
                }
                if (property.NameEquals("provisioningState"))
                {
                    provisioningState = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("uniqueId"))
                {
                    uniqueId = property.Value.GetString();
                    continue;
                }
            }
            return(new CloudServiceProperties(packageUrl.Value, configuration.Value, configurationUrl.Value, Optional.ToNullable(startCloudService), Optional.ToNullable(allowModelOverride), Optional.ToNullable(upgradeMode), roleProfile.Value, osProfile.Value, networkProfile.Value, extensionProfile.Value, provisioningState.Value, uniqueId.Value));
        }