Exemple #1
0
 internal WindowsConfiguration(bool?provisionVMAgent, bool?enableAutomaticUpdates, string timeZone, IList <AdditionalUnattendContent> additionalUnattendContent, WinRMConfiguration winRM)
 {
     ProvisionVMAgent       = provisionVMAgent;
     EnableAutomaticUpdates = enableAutomaticUpdates;
     TimeZone = timeZone;
     AdditionalUnattendContent = additionalUnattendContent;
     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 <WinRMConfiguration> winRM = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("provisionVMAgent"))
                {
                    provisionVMAgent = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("enableAutomaticUpdates"))
                {
                    enableAutomaticUpdates = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("timeZone"))
                {
                    timeZone = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("additionalUnattendContent"))
                {
                    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("winRM"))
                {
                    winRM = WinRMConfiguration.DeserializeWinRMConfiguration(property.Value);
                    continue;
                }
            }
            return(new WindowsConfiguration(Optional.ToNullable(provisionVMAgent), Optional.ToNullable(enableAutomaticUpdates), timeZone.Value, Optional.ToList(additionalUnattendContent), winRM.Value));
        }
Exemple #3
0
        internal static WindowsConfiguration DeserializeWindowsConfiguration(JsonElement element)
        {
            bool?  provisionVMAgent       = default;
            bool?  enableAutomaticUpdates = default;
            string timeZone = default;
            IList <AdditionalUnattendContent> additionalUnattendContent = default;
            WinRMConfiguration winRM = default;

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