public async Task <SpfRecord> Parse(string domain, List <string> spfRecordParts) { string record = string.Join(string.Empty, spfRecordParts); if (string.IsNullOrEmpty(record)) { return(null); } string[] stringTokens = record.Split(Separator, StringSplitOptions.RemoveEmptyEntries); string versionToken = stringTokens.ElementAtOrDefault(0); Domain.Version version = _versionParser.Parse(versionToken); List <Term> terms = stringTokens.Skip(1).Select(_termParser.Parse).ToList(); terms = terms.Concat(_implicitTermProvider.GetImplicitValues(terms)).ToList(); SpfRecord spfRecord = new SpfRecord(spfRecordParts, version, terms); EvaluationResult <DomainSpfRecord> result = await _spfRecordRulesEvaluator.Evaluate(new DomainSpfRecord(domain, spfRecord)); spfRecord.AddErrors(result.Errors); return(spfRecord); }
public SpfRecord Parse(string record, string domain) { if (string.IsNullOrEmpty(record)) { return(null); } string[] stringTokens = record.Split(new[] { Separator }, StringSplitOptions.RemoveEmptyEntries); string versionToken = stringTokens.ElementAtOrDefault(0); Domain.Version version = _versionParser.Parse(versionToken); string explanation; if (_versionExplainer.TryExplain(version, out explanation)) { version.Explanation = explanation; } List <Term> terms = stringTokens.Skip(1).Select(_termParser.Parse).ToList(); terms = terms.Concat(_implicitTermProvider.GetImplicitValues(terms)).ToList(); foreach (Term term in terms) { if (_termExplainer.TryExplain(term, out explanation)) { term.Explanation = explanation; } } SpfRecord spfRecord = new SpfRecord(record, version, terms, domain); spfRecord.AddErrors(_spfRecordRulesEvaluator.Evaluate(spfRecord)); return(spfRecord); }