Beispiel #1
0
        public static bool TryParse(string s, out SpfRecord value)
        {
            if (String.IsNullOrEmpty(s) || !s.StartsWith("v=spf1 "))
            {
                value = null;
                return(false);
            }

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

            value = new SpfRecord {
                Terms = new List <SpfTerm>()
            };

            for (int i = 1; i < terms.Length; i++)
            {
                SpfTerm term;
                if (SpfTerm.TryParse(terms[i], out term))
                {
                    value.Terms.Add(term);
                }
                else
                {
                    value = null;
                    return(false);
                }
            }

            return(true);
        }
Beispiel #2
0
        protected static bool TryParseTerms(string[] terms, out List <SpfTerm> parsedTerms)
        {
            parsedTerms = new List <SpfTerm>(terms.Length - 1);

            for (int i = 1; i < terms.Length; i++)
            {
                SpfTerm term;
                if (SpfTerm.TryParse(terms[i], out term))
                {
                    parsedTerms.Add(term);
                }
                else
                {
                    parsedTerms = null;
                    return(false);
                }
            }

            return(true);
        }