Chimney.MPD.ChimneyMPDServer.GetMyIP C# (CSharp) Method

GetMyIP() private method

private GetMyIP ( ) : HostName
return Windows.Networking.HostName
        private HostName GetMyIP()
        {
            var Host = Windows.Networking.Connectivity.NetworkInformation.GetHostNames();

            var Lan = Windows.Networking.Connectivity.NetworkInformation.GetLanIdentifiers();

            
            Windows.Networking.HostName hostname = null;

            
            foreach (Windows.Networking.HostName hn in Host)
            {
                if (hn.IPInformation != null)
                {
                    if (hn.Type == HostNameType.Ipv4 && hn.IPInformation.NetworkAdapter.IanaInterfaceType == 71)
                    {
                        hostname = hn;
                    }
                }
            }
            

            if (hostname == null)
            {
                foreach (Windows.Networking.Connectivity.LanIdentifier l in Lan)
                {
                    foreach (Windows.Networking.HostName h in Host)
                    {
                        if (h.IPInformation != null)
                        {
                            if (h.IPInformation.NetworkAdapter.NetworkAdapterId == l.NetworkAdapterId)
                            {
                                hostname = h;
                            }
                        }
                    }
                }
            }

            return hostname;
        }