Example #1
0
 internal WindowsConfiguration(bool? provisionVMAgent, bool? enableAutomaticUpdates, string timeZone, IList<AdditionalUnattendContent> additionalUnattendContent, PatchSettings patchSettings, WinRMConfiguration winRM)
 {
     ProvisionVMAgent = provisionVMAgent;
     EnableAutomaticUpdates = enableAutomaticUpdates;
     TimeZone = timeZone;
     AdditionalUnattendContent = additionalUnattendContent;
     PatchSettings = patchSettings;
     WinRM = winRM;
 }
        internal static WindowsConfiguration DeserializeWindowsConfiguration(JsonElement element)
        {
            Optional <bool>   provisionVMAgent       = default;
            Optional <bool>   enableAutomaticUpdates = default;
            Optional <string> timeZone = default;
            Optional <IList <AdditionalUnattendContent> > additionalUnattendContent = default;
            Optional <PatchSettings>      patchSettings = default;
            Optional <WinRMConfiguration> winRM         = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("provisionVMAgent"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    provisionVMAgent = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("enableAutomaticUpdates"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    enableAutomaticUpdates = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("timeZone"))
                {
                    timeZone = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("additionalUnattendContent"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <AdditionalUnattendContent> array = new List <AdditionalUnattendContent>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(Models.AdditionalUnattendContent.DeserializeAdditionalUnattendContent(item));
                    }
                    additionalUnattendContent = array;
                    continue;
                }
                if (property.NameEquals("patchSettings"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    patchSettings = PatchSettings.DeserializePatchSettings(property.Value);
                    continue;
                }
                if (property.NameEquals("winRM"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    winRM = WinRMConfiguration.DeserializeWinRMConfiguration(property.Value);
                    continue;
                }
            }
            return(new WindowsConfiguration(Optional.ToNullable(provisionVMAgent), Optional.ToNullable(enableAutomaticUpdates), timeZone.Value, Optional.ToList(additionalUnattendContent), patchSettings.Value, winRM.Value));
        }