Ejemplo n.º 1
0
        /// <summary>
        /// Saves the current IP Configuration
        /// </summary>
        public async void SaveIPInformation()
        {
            EnableControl = false;
            StatusBarText = "Saving IP Configuration";
            IPConfigurationList ipInfoList = new IPConfigurationList();

            if (!string.IsNullOrWhiteSpace(IPConfigurationItem.IPConfigurationName))
            {
                var item = IPConfigurationList.FirstOrDefault(x => x.IPConfigurationName == IPConfigurationItem.IPConfigurationName);

                if (item == null)
                {
                    IPConfigurationList.Add(IPConfigurationItem);
                }

                foreach (var ipInfo in IPConfigurationList)
                {
                    ipInfoList.IPConfList.Add(ipInfo);
                }

                await Tools.SaveIPInformationListAsync(ipInfoList);

                GetIPInformationList();
                IPConfigurationItem = new IPConfiguration();
                StatusBarText       = "IP Configuration Saved";
            }
            else
            {
                await _dialogMessageService.ShowAsync("Error", "You must enter a valid IP Configuration name");
            }

            EnableControl = true;
        }
        /// <summary>
        /// Applies the sent IP Configuration item
        /// </summary>
        /// <param name="ipConfiguration">The configuration to apply</param>
        /// <param name="adapterName">The adapter which will be updated</param>
        /// <returns>Task type for asynchronous operations</returns>
        public async Task ApplyIPConfigurationAsync(IPConfiguration ipConfiguration, NetworkInterface netInterface,
            IProgress<ProgressReport> progress)
        {
            ProgressReport prgReport = new ProgressReport
            {
                ProgressMessage = "Clearing old settings",
                ProgressValue = 0
            };

            Task ipSetTask = Tools.RunProcess(Tools.BuildNetshParameters(ipConfiguration,
                netInterface.Name, EParameterConfgurationType.IP));

            Task delDnsTask = Tools.RunProcess(Tools.BuildNetshParameters(ipConfiguration,
                netInterface.Name, EParameterConfgurationType.DeleteDNS));

            Task dnsPriSetTask = null;
            Task dnsSecSetTask = null;

            progress.Report(prgReport);
            await delDnsTask;

            if (!string.IsNullOrWhiteSpace(ipConfiguration.PreferredDNS))
            {
                dnsPriSetTask = Tools.RunProcess(Tools.BuildNetshParameters(ipConfiguration,
                netInterface.Name, EParameterConfgurationType.PrimaryDNS));

                prgReport.ProgressMessage = "Applying Preferred DNS";
                prgReport.ProgressValue = (1 * 100 / 5);
                progress.Report(prgReport);
                await dnsPriSetTask;

                if (!string.IsNullOrWhiteSpace(ipConfiguration.SecondaryDNS))
                {
                    dnsSecSetTask = Tools.RunProcess(Tools.BuildNetshParameters(ipConfiguration,
                            netInterface.Name, EParameterConfgurationType.SecondaryDNS));

                    prgReport.ProgressMessage = "Applying Secondary DNS";
                    prgReport.ProgressValue = (2 * 100 / 5);
                    progress.Report(prgReport);
                    await dnsSecSetTask;
                }
            }

            prgReport.ProgressMessage = "Applying IP Configuration";
            prgReport.ProgressValue = (3 * 100 / 5);
            progress.Report(prgReport);
            await ipSetTask;

            prgReport.ProgressMessage = "Validating Configuration";
            prgReport.ProgressValue = (4 * 100 / 5);
            progress.Report(prgReport);
            if (!ValidateInterfaceSettings(ipConfiguration, netInterface))
            {
                throw new Exception("Configure settings do not match the selected configuration");
            }

            prgReport.ProgressMessage = "Configuration Applied";
            prgReport.ProgressValue = (5 * 100 / 5);
            progress.Report(prgReport);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Shows the IP Information selected
 /// </summary>
 /// <param name="ipConfiguration">IPInformation object to show</param>
 public void ShowIPInformation(IPConfiguration ipConfiguration)
 {
     if (ipConfiguration != null)
     {
         IPConfigurationItem = ipConfiguration;
         DisableIPConfigurationDHCP(ipConfiguration.IsDHCP);
     }
 }
Ejemplo n.º 4
0
        public static IPConfiguration GetCurrentInterfaceIPConfiguration(NetworkInterface netInterface, bool getAllInfo = false)
        {
            IPConfiguration configuredIP = null;

            var currentInterface         = NetworkInterface.GetAllNetworkInterfaces().Where(x => x.Name == netInterface.Name).FirstOrDefault();
            var currentAdapterProperties = currentInterface.GetIPProperties();
            var currentIPV4Properties    = currentAdapterProperties.GetIPv4Properties();
            var ipV4Address = currentAdapterProperties.UnicastAddresses.Where(x => x.Address.AddressFamily == AddressFamily.InterNetwork).FirstOrDefault();

            if (!currentIPV4Properties.IsDhcpEnabled)
            {
                configuredIP = new IPConfiguration
                {
                    IPAddress  = ipV4Address.Address.ToString(),
                    SubnetMask = ipV4Address.IPv4Mask.ToString(),
                    Gateway    = currentAdapterProperties.GatewayAddresses.FirstOrDefault().Address.ToString(),
                    IsDHCP     = currentIPV4Properties.IsDhcpEnabled
                };
            }
            else
            {
                if (getAllInfo)
                {
                    configuredIP = new IPConfiguration()
                    {
                        IPAddress  = ipV4Address.Address.ToString(),
                        SubnetMask = ipV4Address.IPv4Mask.ToString(),
                        Gateway    = currentAdapterProperties.GatewayAddresses.FirstOrDefault().Address.ToString(),
                        IsDHCP     = currentIPV4Properties.IsDhcpEnabled
                    };
                }
                else
                {
                    configuredIP = new IPConfiguration
                    {
                        IsDHCP = currentIPV4Properties.IsDhcpEnabled
                    };
                }
            }

            var IPV4Dns = currentAdapterProperties.DnsAddresses.ToList().Where(x => x.AddressFamily == AddressFamily.InterNetwork).ToList();

            for (int i = 0; i < IPV4Dns.Count; i++)
            {
                if (i == 0)
                {
                    configuredIP.PreferredDNS = currentAdapterProperties.DnsAddresses[i].ToString();
                }
                else if (i == 1)
                {
                    configuredIP.SecondaryDNS = currentAdapterProperties.DnsAddresses[i].ToString();
                }
            }

            return(configuredIP);
        }
Ejemplo n.º 5
0
 public AzureHDInsightIPConfiguration(IPConfiguration ipConfiguration)
 {
     Id   = ipConfiguration.Id;
     Name = ipConfiguration.Name;
     Type = ipConfiguration.Type;
     ProvisioningState         = ipConfiguration.ProvisioningState;
     Primary                   = ipConfiguration.Primary;
     PrivateIPAddress          = ipConfiguration.PrivateIPAddress;
     PrivateIPAllocationMethod = ipConfiguration.PrivateIPAllocationMethod;
     Subnet = ipConfiguration.Subnet?.Id;
 }
Ejemplo n.º 6
0
 public IPConfiguration GetConfigurtaion()
 {
     var adapter = (Adapter)comboBox.SelectedItem;
     var configuration = new IPConfiguration();
     configuration.Name = textBoxName.Text;
     configuration.AdapterName = adapter.Name;
     configuration.IpAddress = textBoxIP.Text;
     configuration.Mask = textBoxMask.Text;
     configuration.Gateway = textBoxGateway.Text;
     configuration.DNS = textBoxDNS.Text;
     return configuration;
 }
Ejemplo n.º 7
0
        public static string BuildNetshParameters(IPConfiguration ipInformation,
                                                  string interfaceName, EParameterConfgurationType configType)
        {
            StringBuilder cmdArguments = new StringBuilder();

            switch (configType)
            {
            case EParameterConfgurationType.IP:
                cmdArguments.Append("interface ip set address \"");
                cmdArguments.Append(interfaceName);
                cmdArguments.Append("\"");

                if (ipInformation.IsDHCP)
                {
                    cmdArguments.Append(" dhcp");
                }
                else
                {
                    cmdArguments.Append(" static ");
                    cmdArguments.Append(ipInformation.IPAddress);
                    cmdArguments.Append(" ");
                    cmdArguments.Append(ipInformation.SubnetMask);
                    cmdArguments.Append(" ");
                    cmdArguments.Append(ipInformation.Gateway);
                }
                break;

            case EParameterConfgurationType.PrimaryDNS:
                cmdArguments.Append("interface ip add dns \"");
                cmdArguments.Append(interfaceName);
                cmdArguments.Append("\" ");
                cmdArguments.Append(ipInformation.PreferredDNS);
                break;

            case EParameterConfgurationType.SecondaryDNS:
                cmdArguments.Append("interface ip add dns \"");
                cmdArguments.Append(interfaceName);
                cmdArguments.Append("\" ");
                cmdArguments.Append(ipInformation.SecondaryDNS);
                cmdArguments.Append(" index=2");
                break;

            case EParameterConfgurationType.DeleteDNS:
                cmdArguments.Append("interface ip delete dns \"");
                cmdArguments.Append(interfaceName);
                cmdArguments.Append("\" all");
                break;
            }

            return(cmdArguments.ToString());
        }
        /// <summary>
        /// Validates that the current configuration matches the selected configuration
        /// </summary>
        /// <param name="ipConfiguration">Selected configuration</param>
        /// <param name="netInterface">Current configuration for the selected adapter</param>
        /// <returns>true if configuration matches</returns>
        private bool ValidateInterfaceSettings(IPConfiguration ipConfiguration, NetworkInterface netInterface)
        {
            bool result = false;

            IPConfiguration configuredIP = Tools.GetCurrentInterfaceIPConfiguration(netInterface);

            if (configuredIP != null)
            {
                if (ipConfiguration.Equals(configuredIP))
                {
                    result = true;
                }
            }

            return result;
        }
Ejemplo n.º 9
0
        public void SetConfiguration(IPConfiguration configuration)
        {
            textBoxName.Text = configuration.Name;
            textBoxIP.Text = configuration.IpAddress;
            textBoxMask.Text = configuration.Mask;
            textBoxGateway.Text = configuration.Gateway;
            textBoxDNS.Text = configuration.DNS;

            foreach (var item in comboBox.Items)
            {
                var adapter = (Adapter)item;
                if (adapter.Name.CompareTo(configuration.AdapterName) == 0)
                {
                    comboBox.SelectedItem = adapter;
                }
            }
        }
Ejemplo n.º 10
0
        public Form1()
        {
            InitializeComponent();
            FormClosing += new FormClosingEventHandler(Form1_FormClosing);
            _configuration = new BindingList<IPConfiguration>();

            _configuration.Clear();
            foreach (var s in Properties.Settings.Default.ConfigurationStrings )
            {
                var cmd = new CmdLineHelper();
                cmd.ParseString(s);
                var config = new IPConfiguration();
                config.Configure(cmd);
                _configuration.Add(config);
            }
            UpdateContextMenu();
        }
        /// <summary>
        /// Saves the IP Configuration instance
        /// </summary>
        /// <param name="ipInformationEntry">IP Configuration instance to save</param>
        /// <returns>Integer indicating wether the operation was successful</returns>
        public async Task<int> SaveIPInformationEntryAsync(IPConfiguration ipInformationEntry)
        {
            int result = 0;

            try
            {
                IPConfigurationList infoList = new IPConfigurationList();
                infoList.IPConfList.Add(ipInformationEntry);
                await Tools.SaveIPInformationListAsync(infoList);
            }
            catch (Exception)
            {
                result = -1;
            }

            return result;
        }
Ejemplo n.º 12
0
 internal PublicIPAddressData(string id, string name, string type, string location, IDictionary <string, string> tags, ExtendedLocation extendedLocation, PublicIPAddressSku sku, string etag, IList <string> zones, IPAllocationMethod?publicIPAllocationMethod, IPVersion?publicIPAddressVersion, IPConfiguration ipConfiguration, PublicIPAddressDnsSettings dnsSettings, DdosSettings ddosSettings, IList <IpTag> ipTags, string ipAddress, SubResource publicIPPrefix, int?idleTimeoutInMinutes, string resourceGuid, ProvisioningState?provisioningState, PublicIPAddressData servicePublicIPAddress, NatGatewayData natGateway, PublicIPAddressMigrationPhase?migrationPhase, PublicIPAddressData linkedPublicIPAddress, DeleteOptions?deleteOption) : base(id, name, type, location, tags)
 {
     ExtendedLocation = extendedLocation;
     Sku   = sku;
     Etag  = etag;
     Zones = zones;
     PublicIPAllocationMethod = publicIPAllocationMethod;
     PublicIPAddressVersion   = publicIPAddressVersion;
     IpConfiguration          = ipConfiguration;
     DnsSettings            = dnsSettings;
     DdosSettings           = ddosSettings;
     IpTags                 = ipTags;
     IpAddress              = ipAddress;
     PublicIPPrefix         = publicIPPrefix;
     IdleTimeoutInMinutes   = idleTimeoutInMinutes;
     ResourceGuid           = resourceGuid;
     ProvisioningState      = provisioningState;
     ServicePublicIPAddress = servicePublicIPAddress;
     NatGateway             = natGateway;
     MigrationPhase         = migrationPhase;
     LinkedPublicIPAddress  = linkedPublicIPAddress;
     DeleteOption           = deleteOption;
 }
Ejemplo n.º 13
0
        public IPConfigurationViewModel(IIPConfigurationService ipInformationService,
                                        IDialogMessageService dialogMessageService)
        {
            _ipInformationService      = ipInformationService;
            _dialogMessageService      = dialogMessageService;
            IPConfigurationList        = new ObservableCollection <IPConfiguration>();
            IPConfigurationItem        = new IPConfiguration();
            AvailableNetworkInterfaces = new ObservableCollection <NetworkInterface>();
            ProgressReport prgReport = new ProgressReport
            {
                ProgressMessage = "Ready",
                ProgressValue   = 0
            };

            GetAllIPInfoCommand               = new RelayCommand(GetIPInformationList);
            SaveCommand                       = new RelayCommand(SaveIPInformation);
            ShowIPInformationCommand          = new RelayCommand <IPConfiguration>(ShowIPInformation);
            SelectNetworkInterfaceCommand     = new RelayCommand <NetworkInterface>(SelectNetworkAdapter);
            ApplyIPConfigurationCommand       = new RelayCommand(ApplyIPConfiguration);
            DisableIPConfigurationDHCPCommand = new RelayCommand <bool>(DisableIPConfigurationDHCP);
            EnableIPTextBoxes                 = true;
            EnableControl                     = true;
            ReportProgress(prgReport);
        }
Ejemplo n.º 14
0
        internal static SubnetData DeserializeSubnetData(JsonElement element)
        {
            Optional <string>                   name                                    = default;
            Optional <string>                   etag                                    = default;
            Optional <string>                   type                                    = default;
            Optional <string>                   id                                      = default;
            Optional <string>                   addressPrefix                           = default;
            Optional <IList <string> >          addressPrefixes                         = default;
            Optional <NetworkSecurityGroupData> networkSecurityGroup                    = default;
            Optional <RouteTableData>           routeTable                              = default;
            Optional <WritableSubResource>      natGateway                              = default;
            Optional <IList <ServiceEndpointPropertiesFormat> > serviceEndpoints        = default;
            Optional <IList <ServiceEndpointPolicyData> >       serviceEndpointPolicies = default;
            Optional <IReadOnlyList <PrivateEndpointData> >     privateEndpoints        = default;
            Optional <IReadOnlyList <IPConfiguration> >         ipConfigurations        = default;
            Optional <IReadOnlyList <IPConfigurationProfile> >  ipConfigurationProfiles = default;
            Optional <IList <WritableSubResource> >             ipAllocations           = default;
            Optional <IReadOnlyList <ResourceNavigationLink> >  resourceNavigationLinks = default;
            Optional <IReadOnlyList <ServiceAssociationLink> >  serviceAssociationLinks = default;
            Optional <IList <Delegation> > delegations                                  = default;
            Optional <string>            purpose           = default;
            Optional <ProvisioningState> provisioningState = default;
            Optional <VirtualNetworkPrivateEndpointNetworkPolicies>    privateEndpointNetworkPolicies     = default;
            Optional <VirtualNetworkPrivateLinkServiceNetworkPolicies> privateLinkServiceNetworkPolicies  = default;
            Optional <IList <ApplicationGatewayIPConfiguration> >      applicationGatewayIpConfigurations = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("etag"))
                {
                    etag = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("addressPrefix"))
                        {
                            addressPrefix = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("addressPrefixes"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <string> array = new List <string>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(item.GetString());
                            }
                            addressPrefixes = array;
                            continue;
                        }
                        if (property0.NameEquals("networkSecurityGroup"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            networkSecurityGroup = NetworkSecurityGroupData.DeserializeNetworkSecurityGroupData(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("routeTable"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            routeTable = RouteTableData.DeserializeRouteTableData(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("natGateway"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            natGateway = JsonSerializer.Deserialize <WritableSubResource>(property0.Value.ToString());
                            continue;
                        }
                        if (property0.NameEquals("serviceEndpoints"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ServiceEndpointPropertiesFormat> array = new List <ServiceEndpointPropertiesFormat>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ServiceEndpointPropertiesFormat.DeserializeServiceEndpointPropertiesFormat(item));
                            }
                            serviceEndpoints = array;
                            continue;
                        }
                        if (property0.NameEquals("serviceEndpointPolicies"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ServiceEndpointPolicyData> array = new List <ServiceEndpointPolicyData>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ServiceEndpointPolicyData.DeserializeServiceEndpointPolicyData(item));
                            }
                            serviceEndpointPolicies = array;
                            continue;
                        }
                        if (property0.NameEquals("privateEndpoints"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <PrivateEndpointData> array = new List <PrivateEndpointData>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(PrivateEndpointData.DeserializePrivateEndpointData(item));
                            }
                            privateEndpoints = array;
                            continue;
                        }
                        if (property0.NameEquals("ipConfigurations"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <IPConfiguration> array = new List <IPConfiguration>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(IPConfiguration.DeserializeIPConfiguration(item));
                            }
                            ipConfigurations = array;
                            continue;
                        }
                        if (property0.NameEquals("ipConfigurationProfiles"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <IPConfigurationProfile> array = new List <IPConfigurationProfile>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(IPConfigurationProfile.DeserializeIPConfigurationProfile(item));
                            }
                            ipConfigurationProfiles = array;
                            continue;
                        }
                        if (property0.NameEquals("ipAllocations"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <WritableSubResource> array = new List <WritableSubResource>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(JsonSerializer.Deserialize <WritableSubResource>(item.ToString()));
                            }
                            ipAllocations = array;
                            continue;
                        }
                        if (property0.NameEquals("resourceNavigationLinks"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ResourceNavigationLink> array = new List <ResourceNavigationLink>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ResourceNavigationLink.DeserializeResourceNavigationLink(item));
                            }
                            resourceNavigationLinks = array;
                            continue;
                        }
                        if (property0.NameEquals("serviceAssociationLinks"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ServiceAssociationLink> array = new List <ServiceAssociationLink>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ServiceAssociationLink.DeserializeServiceAssociationLink(item));
                            }
                            serviceAssociationLinks = array;
                            continue;
                        }
                        if (property0.NameEquals("delegations"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <Delegation> array = new List <Delegation>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(Delegation.DeserializeDelegation(item));
                            }
                            delegations = array;
                            continue;
                        }
                        if (property0.NameEquals("purpose"))
                        {
                            purpose = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("provisioningState"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            provisioningState = new ProvisioningState(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("privateEndpointNetworkPolicies"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            privateEndpointNetworkPolicies = new VirtualNetworkPrivateEndpointNetworkPolicies(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("privateLinkServiceNetworkPolicies"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            privateLinkServiceNetworkPolicies = new VirtualNetworkPrivateLinkServiceNetworkPolicies(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("applicationGatewayIpConfigurations"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ApplicationGatewayIPConfiguration> array = new List <ApplicationGatewayIPConfiguration>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ApplicationGatewayIPConfiguration.DeserializeApplicationGatewayIPConfiguration(item));
                            }
                            applicationGatewayIpConfigurations = array;
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new SubnetData(id.Value, name.Value, etag.Value, type.Value, addressPrefix.Value, Optional.ToList(addressPrefixes), networkSecurityGroup.Value, routeTable.Value, natGateway, Optional.ToList(serviceEndpoints), Optional.ToList(serviceEndpointPolicies), Optional.ToList(privateEndpoints), Optional.ToList(ipConfigurations), Optional.ToList(ipConfigurationProfiles), Optional.ToList(ipAllocations), Optional.ToList(resourceNavigationLinks), Optional.ToList(serviceAssociationLinks), Optional.ToList(delegations), purpose.Value, Optional.ToNullable(provisioningState), Optional.ToNullable(privateEndpointNetworkPolicies), Optional.ToNullable(privateLinkServiceNetworkPolicies), Optional.ToList(applicationGatewayIpConfigurations)));
        }
Ejemplo n.º 15
0
        internal static PublicIPAddressData DeserializePublicIPAddressData(JsonElement element)
        {
            Optional <ExtendedLocation>              extendedLocation = default;
            Optional <PublicIPAddressSku>            sku      = default;
            Optional <string>                        etag     = default;
            Optional <IList <string> >               zones    = default;
            Optional <string>                        id       = default;
            Optional <string>                        name     = default;
            Optional <string>                        type     = default;
            Optional <string>                        location = default;
            Optional <IDictionary <string, string> > tags     = default;
            Optional <IPAllocationMethod>            publicIPAllocationMethod = default;
            Optional <IPVersion>                     publicIPAddressVersion   = default;
            Optional <IPConfiguration>               ipConfiguration          = default;
            Optional <PublicIPAddressDnsSettings>    dnsSettings            = default;
            Optional <DdosSettings>                  ddosSettings           = default;
            Optional <IList <IpTag> >                ipTags                 = default;
            Optional <string>                        ipAddress              = default;
            Optional <WritableSubResource>           publicIPPrefix         = default;
            Optional <int>                           idleTimeoutInMinutes   = default;
            Optional <string>                        resourceGuid           = default;
            Optional <ProvisioningState>             provisioningState      = default;
            Optional <PublicIPAddressData>           servicePublicIPAddress = default;
            Optional <NatGatewayData>                natGateway             = default;
            Optional <PublicIPAddressMigrationPhase> migrationPhase         = default;
            Optional <PublicIPAddressData>           linkedPublicIPAddress  = default;
            Optional <DeleteOptions>                 deleteOption           = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("extendedLocation"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    extendedLocation = ExtendedLocation.DeserializeExtendedLocation(property.Value);
                    continue;
                }
                if (property.NameEquals("sku"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    sku = PublicIPAddressSku.DeserializePublicIPAddressSku(property.Value);
                    continue;
                }
                if (property.NameEquals("etag"))
                {
                    etag = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("zones"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    zones = array;
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("location"))
                {
                    location = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    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("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("publicIPAllocationMethod"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            publicIPAllocationMethod = new IPAllocationMethod(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("publicIPAddressVersion"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            publicIPAddressVersion = new IPVersion(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("ipConfiguration"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            ipConfiguration = IPConfiguration.DeserializeIPConfiguration(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("dnsSettings"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            dnsSettings = PublicIPAddressDnsSettings.DeserializePublicIPAddressDnsSettings(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("ddosSettings"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            ddosSettings = DdosSettings.DeserializeDdosSettings(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("ipTags"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <IpTag> array = new List <IpTag>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(IpTag.DeserializeIpTag(item));
                            }
                            ipTags = array;
                            continue;
                        }
                        if (property0.NameEquals("ipAddress"))
                        {
                            ipAddress = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("publicIPPrefix"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            publicIPPrefix = JsonSerializer.Deserialize <WritableSubResource>(property0.Value.ToString());
                            continue;
                        }
                        if (property0.NameEquals("idleTimeoutInMinutes"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            idleTimeoutInMinutes = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("resourceGuid"))
                        {
                            resourceGuid = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("provisioningState"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            provisioningState = new ProvisioningState(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("servicePublicIPAddress"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            servicePublicIPAddress = DeserializePublicIPAddressData(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("natGateway"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            natGateway = NatGatewayData.DeserializeNatGatewayData(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("migrationPhase"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            migrationPhase = new PublicIPAddressMigrationPhase(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("linkedPublicIPAddress"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            linkedPublicIPAddress = DeserializePublicIPAddressData(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("deleteOption"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            deleteOption = new DeleteOptions(property0.Value.GetString());
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new PublicIPAddressData(id.Value, name.Value, type.Value, location.Value, Optional.ToDictionary(tags), extendedLocation.Value, sku.Value, etag.Value, Optional.ToList(zones), Optional.ToNullable(publicIPAllocationMethod), Optional.ToNullable(publicIPAddressVersion), ipConfiguration.Value, dnsSettings.Value, ddosSettings.Value, Optional.ToList(ipTags), ipAddress.Value, publicIPPrefix, Optional.ToNullable(idleTimeoutInMinutes), resourceGuid.Value, Optional.ToNullable(provisioningState), servicePublicIPAddress.Value, natGateway.Value, Optional.ToNullable(migrationPhase), linkedPublicIPAddress.Value, Optional.ToNullable(deleteOption)));
        }
Ejemplo n.º 16
0
        internal static InboundEndpointData DeserializeInboundEndpointData(JsonElement element)
        {
            Optional <string>            etag = default;
            IDictionary <string, string> tags = default;
            AzureLocation      location       = default;
            ResourceIdentifier id             = default;
            string             name           = default;
            ResourceType       type           = default;
            SystemData         systemData     = default;
            Optional <IList <IPConfiguration> > ipConfigurations  = default;
            Optional <ProvisioningState>        provisioningState = default;
            Optional <string> resourceGuid = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("etag"))
                {
                    etag = property.Value.GetString();
                    continue;
                }
                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 = 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 = 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("ipConfigurations"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <IPConfiguration> array = new List <IPConfiguration>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(IPConfiguration.DeserializeIPConfiguration(item));
                            }
                            ipConfigurations = array;
                            continue;
                        }
                        if (property0.NameEquals("provisioningState"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            provisioningState = new ProvisioningState(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("resourceGuid"))
                        {
                            resourceGuid = property0.Value.GetString();
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new InboundEndpointData(id, name, type, systemData, tags, location, etag.Value, Optional.ToList(ipConfigurations), Optional.ToNullable(provisioningState), resourceGuid.Value));
        }