Exemplo n.º 1
0
        internal static async Task <IPEndPoint> ParseIPEndPoint(XmlElement root, byte[] subnet = null)
        {
            if (!root.HasAttribute("Address"))
            {
                throw new FormatException("Missing Address attribute for " + root.LocalName + " element");
            }
            if (!root.HasAttribute("Port"))
            {
                throw new FormatException("Missing Port attribute for " + root.LocalName + " element");
            }

            var family = AddressFamily.InterNetwork;

            if (root.HasAttribute("Subnet"))
            {
                subnet = ParseSubnet(root.GetAttribute("Subnet"), "Invalid subnet");
            }
            if (root.HasAttribute("PreferredFamily"))
            {
                family = ParseEnum <AddressFamily>(root.GetAttribute("PreferredFamily"),
                                                   "Invalid preferred addressing family for " + root.LocalName + " element");
            }
            IPAddress addr = await ClusterConfiguration.ResolveIPAddress(root.GetAttribute("Address"), subnet, family);

            int port = ParseInt(root.GetAttribute("Port"), "Invalid Port attribute for " + root.LocalName + " element");

            return(new IPEndPoint(addr, port));
        }