Beispiel #1
0
        /// <summary>
        /// Extracts IP address from XML element
        /// </summary>
        /// <param name="addressElement">XML element containing IP address</param>
        /// <returns>IpAddress object, containing information about IP address</returns>
        public static IpAddress Extract(XElement addressElement)
        {
            XAttribute    typeAttr = addressElement.Attribute("ip");
            IpAddressType type     = typeAttr == null ? IpAddressType.V4 : typeAttr.Value.ToEnum <IpAddressType>();

            return(new IpAddress(type, addressElement.Value));
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the IpAddress class with specified type and address
        /// </summary>
        /// <param name="type">IP address type</param>
        /// <param name="address">IP address</param>
        public IpAddress(IpAddressType type, string address)
        {
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }

            this.Type    = type;
            this.Address = address;
        }
Beispiel #3
0
        public void Test()
        {
            const string test   = "SomeIp ::= IpAddress";
            Lexer        lexer  = new Lexer();
            StringReader reader = new StringReader(test);

            lexer.Parse(reader);
            string name = lexer.NextSymbol.ToString();

            lexer.NextSymbol.Expect(Symbol.Assign);
            lexer.NextSymbol.Expect(Symbol.IpAddress);

            IpAddressType i = new IpAddressType("module", "name", lexer);
        }
Beispiel #4
0
        /// <summary>
        /// 获取主机地址类型
        /// </summary>
        /// <param name="host"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static bool GetHostAddressType(string host, out IpAddressType type)
        {
            if (SYS_IsIPAddress(host, out type))
            {
                return(true);
            }

            var reg = new Regex(@"^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$", RegexOptions.IgnoreCase);

            if (reg.IsMatch(host))
            {
                type = IpAddressType.Domain;
                return(true);
            }

            return(false);
        }
Beispiel #5
0
 public static extern bool SYS_GetIPAddress(string lpszHost, [MarshalAs(UnmanagedType.LPStr)] StringBuilder lpszIp, ref int piIpLength, ref IpAddressType penType);
Beispiel #6
0
 public static extern bool SYS_IsIPAddress(string lpszAddress, out IpAddressType penType);
Beispiel #7
0
 public static extern bool SYS_EnumHostIPAddresses(string lpszHost, IpAddressType enType, ref IntPtr lpppIpAddr, ref int piIpAddrCount);