public void UpdateConnection()

in WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/DefaultDevicePortalConnection.cs [109:147]


        public void UpdateConnection(
            IpConfiguration ipConfig,
            bool requiresHttps,
            bool preservePort)
        {
            Uri newConnection = null;

            foreach (NetworkAdapterInfo adapter in ipConfig.Adapters)
            {
                foreach (IpAddressInfo addressInfo in adapter.IpAddresses)
                {
                    // We take the first, non-169.x.x.x address we find that is not 0.0.0.0.
                    if ((addressInfo.Address != "0.0.0.0") && !addressInfo.Address.StartsWith("169."))
                    {
                        string address = addressInfo.Address;
                        if (preservePort)
                        {
                            address = string.Format(
                                "{0}:{1}",
                                address,
                                this.Connection.Port);
                        }

                        newConnection = new Uri(
                            string.Format(
                                "{0}://{1}", 
                                requiresHttps ? "https" : "http",
                                address));
                        break;
                    }
                }

                if (newConnection != null)
                {
                    this.Connection = newConnection;
                    break;
                }
            }
        }