Esempio n. 1
0
        /// <summary>
        ///   Checks, whether a given string starts with a correct SenderID prefix of a given scope
        /// </summary>
        /// <param name="s"> Textual representation to check </param>
        /// <param name="scope"> Scope, which should be matched </param>
        /// <returns> true in case of correct prefix </returns>
        public static bool IsSenderIDRecord(string s, SenderIDScope scope)
        {
            if (String.IsNullOrEmpty(s))
            {
                return(false);
            }

            string[] terms = s.Split(new[] { ' ' }, 2);

            if (terms.Length < 2)
            {
                return(false);
            }

            int version;
            int minor;
            List <SenderIDScope> scopes;

            if (!TryParsePrefix(terms[0], out version, out minor, out scopes))
            {
                return(false);
            }

            if ((version == 1) && ((scope == SenderIDScope.MFrom) || (scope == SenderIDScope.Pra)))
            {
                return(true);
            }
            else
            {
                return(scopes.Contains(scope));
            }
        }
Esempio n. 2
0
        /// <summary>
        ///   Checks, whether a given string starts with a correct SenderID prefix of a given scope
        /// </summary>
        /// <param name="s"> Textual representation to check </param>
        /// <param name="scope"> Scope, which should be matched </param>
        /// <returns> true in case of correct prefix </returns>
        public static bool IsSenderIDRecord(string s, SenderIDScope scope)
        {
            if (String.IsNullOrEmpty(s))
                return false;

            string[] terms = s.Split(new[] { ' ' }, 2);

            if (terms.Length < 2)
                return false;

            int version;
            int minor;
            List<SenderIDScope> scopes;
            if (!TryParsePrefix(terms[0], out version, out minor, out scopes))
            {
                return false;
            }

            if ((version == 1) && ((scope == SenderIDScope.MFrom) || (scope == SenderIDScope.Pra)))
            {
                return true;
            }
            else
            {
                return scopes.Contains(scope);
            }
        }
Esempio n. 3
0
 /// <summary>
 ///   Initializes a new instance of the SenderIDValidator class.
 /// </summary>
 public SenderIDValidator()
 {
     Scope = SenderIDScope.MFrom;
 }