示例#1
0
 internal RestorePointSourceMetadata(HardwareProfile hardwareProfile, RestorePointSourceVmStorageProfile storageProfile, OSProfile osProfile, DiagnosticsProfile diagnosticsProfile, string licenseType, string vmId, SecurityProfile securityProfile, AzureLocation?location)
 {
     HardwareProfile    = hardwareProfile;
     StorageProfile     = storageProfile;
     OSProfile          = osProfile;
     DiagnosticsProfile = diagnosticsProfile;
     LicenseType        = licenseType;
     VmId            = vmId;
     SecurityProfile = securityProfile;
     Location        = location;
 }
        internal static RestorePointSourceMetadata DeserializeRestorePointSourceMetadata(JsonElement element)
        {
            Optional <HardwareProfile> hardwareProfile = default;
            Optional <RestorePointSourceVmStorageProfile> storageProfile = default;
            Optional <OSProfile>          osProfile          = default;
            Optional <DiagnosticsProfile> diagnosticsProfile = default;
            Optional <string>             licenseType        = default;
            Optional <string>             vmId            = default;
            Optional <SecurityProfile>    securityProfile = default;
            Optional <string>             location        = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("hardwareProfile"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    hardwareProfile = HardwareProfile.DeserializeHardwareProfile(property.Value);
                    continue;
                }
                if (property.NameEquals("storageProfile"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    storageProfile = RestorePointSourceVmStorageProfile.DeserializeRestorePointSourceVmStorageProfile(property.Value);
                    continue;
                }
                if (property.NameEquals("osProfile"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    osProfile = OSProfile.DeserializeOSProfile(property.Value);
                    continue;
                }
                if (property.NameEquals("diagnosticsProfile"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    diagnosticsProfile = DiagnosticsProfile.DeserializeDiagnosticsProfile(property.Value);
                    continue;
                }
                if (property.NameEquals("licenseType"))
                {
                    licenseType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("vmId"))
                {
                    vmId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("securityProfile"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    securityProfile = SecurityProfile.DeserializeSecurityProfile(property.Value);
                    continue;
                }
                if (property.NameEquals("location"))
                {
                    location = property.Value.GetString();
                    continue;
                }
            }
            return(new RestorePointSourceMetadata(hardwareProfile.Value, storageProfile.Value, osProfile.Value, diagnosticsProfile.Value, licenseType.Value, vmId.Value, securityProfile.Value, location.Value));
        }