using System;

namespace FilterAPI
{
    public class Injection
    {
        public static Boolean ContainsOnlyLetterOrDigit(String Text)
        {
            foreach (Char Value in Text)
            {
                if (!Char.IsLetterOrDigit(Value)) { return false; }
            }

            return true;
        }

        public static Boolean IsInt32(String Text)
        {
            try
            {
                Convert.ToInt32(Text);

                return true;
            }
            catch { return false; }
        }

        public static Boolean ContainsInvalidSymbol(String Message, Boolean Roar, out Char InvalidSymbol)
        {
            foreach (Char Value in Message)
            {
                if (!Char.IsLetterOrDigit(Value)
                    && Value != Convert.ToChar("'")
                    && Value != ' '
                    && Value != '#'
                    && Value != '$'
                    && Value != '.'
                    && Value != ','
                    && Value != '!'
                    && Value != '@'
                    && Value != '^'
                    && Value != '&'
                    && Value != ':'
                    && Value != ';'
                    && Value != '\\'
                    && Value != '-'
                    && Value != '_'
                    && Value != '+'
                    && Value != '='
                    && Value != '"'
                    && Value != '<'
                    && Value != '>'
                    && Value != '/'
                    && Value != '~'
                    && Value != '?'
                    && Value != '['
                    && Value != ']'
                    && Value != '('
                    && Value != 'ß'
                    && Value != '§'
                    && Value != '€'
                    && Value != ')')
                {
                    InvalidSymbol = Value;

                    return true;
                }
            }

            InvalidSymbol = '.';

            return false;
        }

       public static Boolean ContainsInvalidSymbol(String Message, out Char InvalidSymbol)
        {
            foreach (Char Value in Message)
            {
                if (!Char.IsLetterOrDigit(Value)
                    && Value != Convert.ToChar("'")
                    && Value != ' '
                    && Value != '#'
                    && Value != '$'
                    && Value != '.'
                    && Value != ','
                    && Value != '!'
                    && Value != '@'
                    && Value != '^'
                    && Value != '&'
                    && Value != '*'
                    && Value != ':'
                    && Value != ';'
                    && Value != '\\'
                    && Value != '-'
                    && Value != '_'
                    && Value != '+'
                    && Value != '='
                    && Value != '"'
                    && Value != '<'
                    && Value != '>'
                    && Value != '/'
                    && Value != '~'
                    && Value != '?'
                    && Value != '['
                    && Value != ']'
                    && Value != '('
                    && Value != '%'
                    && Value != 'ß'
                    && Value != '§'
                    && Value != '€'
                    && Value != ')')
                {
                    InvalidSymbol = Value;

                    return true;
                }
            }

            InvalidSymbol = '.';

            return false;
        }

        public static Boolean CheckPSC(String Message)
        {
            foreach (Char Value in Message)
            {
                if (!Char.IsDigit(Value)
                    && Value != ' '
                    && Value != '-') { return true; }
            }

            return false;
        }
    }
}
