/// <summary> /// Converts the <see cref="sourceValue" /> parameter to the <see cref="destinationType" /> parameter using <see cref="formatProvider" /// /> and <see cref="ignoreCase" /> /// </summary> /// <param name="sourceValue">the <see cref="System.Object"/> to convert from</param> /// <param name="destinationType">the <see cref="System.Type" /> to convert to</param> /// <param name="formatProvider">not used by this TypeConverter.</param> /// <param name="ignoreCase">when set to <c>true</c>, will ignore the case when converting.</param> /// <returns> /// an instance of <see cref="CloudServiceUpgradeMode" />, or <c>null</c> if there is no suitable conversion. /// </returns> public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => CloudServiceUpgradeMode.CreateFrom(sourceValue);
internal static CloudServiceData DeserializeCloudServiceData(JsonElement element) { IDictionary <string, string> tags = default; AzureLocation location = default; ResourceIdentifier id = default; string name = default; ResourceType type = default; SystemData systemData = default; Optional <Uri> packageUrl = default; Optional <string> configuration = default; Optional <Uri> 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("tags")) { Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (var property0 in property.Value.EnumerateObject()) { dictionary.Add(property0.Name, property0.Value.GetString()); } tags = dictionary; continue; } if (property.NameEquals("location")) { location = new AzureLocation(property.Value.GetString()); continue; } if (property.NameEquals("id")) { id = new ResourceIdentifier(property.Value.GetString()); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = new ResourceType(property.Value.GetString()); continue; } if (property.NameEquals("systemData")) { systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString()); continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("packageUrl")) { if (property0.Value.ValueKind == JsonValueKind.Null) { packageUrl = null; continue; } packageUrl = new Uri(property0.Value.GetString()); continue; } if (property0.NameEquals("configuration")) { configuration = property0.Value.GetString(); continue; } if (property0.NameEquals("configurationUrl")) { if (property0.Value.ValueKind == JsonValueKind.Null) { configurationUrl = null; continue; } configurationUrl = new Uri(property0.Value.GetString()); continue; } if (property0.NameEquals("startCloudService")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } startCloudService = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("allowModelOverride")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } allowModelOverride = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("upgradeMode")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } upgradeMode = new CloudServiceUpgradeMode(property0.Value.GetString()); continue; } if (property0.NameEquals("roleProfile")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } roleProfile = CloudServiceRoleProfile.DeserializeCloudServiceRoleProfile(property0.Value); continue; } if (property0.NameEquals("osProfile")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } osProfile = CloudServiceOSProfile.DeserializeCloudServiceOSProfile(property0.Value); continue; } if (property0.NameEquals("networkProfile")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } networkProfile = CloudServiceNetworkProfile.DeserializeCloudServiceNetworkProfile(property0.Value); continue; } if (property0.NameEquals("extensionProfile")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } extensionProfile = CloudServiceExtensionProfile.DeserializeCloudServiceExtensionProfile(property0.Value); continue; } if (property0.NameEquals("provisioningState")) { provisioningState = property0.Value.GetString(); continue; } if (property0.NameEquals("uniqueId")) { uniqueId = property0.Value.GetString(); continue; } } continue; } } return(new CloudServiceData(id, name, type, systemData, tags, location, 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)); }