Ejemplo n.º 1
0
        public PatentLinks(PatentNumber number)
        {
            if (number == null)
            {
                throw new ArgumentNullException(nameof(number));
            }

            Espacenet     = string.Concat("https://worldwide.espacenet.com/patent/search/publication/", number.Format());
            FullText      = string.Format(ToolsContext.Current.Settings.PatentPDFServer, number.Format());
            GooglePatents = string.Concat("https://patents.google.com/?q=", number.Format());
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Parses the input to a patent number.
        /// </summary>
        /// <param name="input">The input.</param>
        /// <returns>The patent number.</returns>
        public static PatentNumber Parse(string input)
        {
            if (string.IsNullOrEmpty(input))
            {
                throw new ArgumentNullException(nameof(input));
            }

            // first clean
            input = input.ToUpper().Trim();

            // remove non alphanumeric characters
            var regex = new Regex("[^a-zA-Z0-9]");

            input = regex.Replace(input, string.Empty);

            // validation
            if (input.Length <= 3)
            {
                throw new ArgumentException("number is too short");
            }

            var result = new PatentNumber();
            var size   = input.Length;

            // country code
            result.C = input.Substring(0, 2);

            // kind code
            result.K = char.IsLetter(input[size - 2])
                ? string.Concat(input[size - 2], input[size - 1])
                : string.Concat(input[size - 1]);

            // document number
            result.N = input.Substring(result.C.Length, size - result.C.Length - result.K.Length);

            return(result);
        }