示例#1
0
        public Tag Parse(string tag, string value)
        {
            int candidatePercentValue;
            int?percentValue = null;

            if (int.TryParse(value, out candidatePercentValue) && candidatePercentValue <= 100 && candidatePercentValue >= 0)
            {
                percentValue = candidatePercentValue;
            }

            Percent percent = new Percent(tag, percentValue);

            if (!percentValue.HasValue)
            {
                string errorMessage = string.Format(DmarcParserResource.InvalidValueErrorMessage, Tag, value);
                percent.AddError(new Error(ErrorType.Error, errorMessage));
            }

            return(percent);
        }