Пример #1
0
        /*
         * FUNCTION    : ValidateIP
         * DESCRIPTION : Checks to see if the given ip is valid
         * PARAMETERS  : NONE
         * RETURNS     : NONE
         */
        private void ValidateIP()
        {
            string pattern = @"^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$";

            Regex check = new Regex(pattern);

            if (check.IsMatch(ip, 0) == false)
            {
                ValidationFault ipFault = new ValidationFault
                {
                    Message = "The IP given is invalid - Service was given: ",
                };

                logger.Log(LoggingInfo.ErrorLevel.FATAL, ipFault.Message + ip);

                throw new FaultException <ValidationFault>(ipFault, ipFault.Message + ip);
            }
        }
Пример #2
0
        //
        private void ValidateIP()
        {
            string pattern = @"^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$";

            Regex check = new Regex(pattern);

            if (check.IsMatch(ip, 0) == false)
            {
                ValidationFault ipFault = new ValidationFault
                {
                    Result      = false,
                    Message     = "The IP given is invalid - Service was given: ",
                    Description = "Invalid IP"
                };


                throw new FaultException <ValidationFault>(ipFault, ipFault.Message + ip);
            }
        }