예제 #1
0
        protected override void ValidateRead(List <ValidationError> errors)
        {
            if (this.Words == null || this.Words.Length == 0)
            {
                errors.Add(new RulePhrase.RulePhraseValidationError(RulesTasksStrings.ArgumentNotSet, base.Name));
                return;
            }
            List <string> list = (from w in this.Words
                                  select w.ToString()).ToList <string>();
            List <KeyValuePair <string, List <string> > > source = AttachmentPropertyContainsPredicate.ParsePredicateParameters(list);

            if (!source.Any <KeyValuePair <string, List <string> > >())
            {
                errors.Add(new RulePhrase.RulePhraseValidationError(RulesTasksStrings.AttachmentMetadataPropertyNotSpecified(string.Join(", ", list)), base.Name));
                return;
            }
            Word[] words = this.Words;
            int    i     = 0;

            while (i < words.Length)
            {
                Word     word  = words[i];
                string   value = word.Value;
                string[] array = value.Split(new char[]
                {
                    ':'
                });
                if (array.Length < 2 || (array.Length >= 2 && (string.IsNullOrWhiteSpace(array[0]) || string.IsNullOrWhiteSpace(array[1]))))
                {
                    errors.Add(new RulePhrase.RulePhraseValidationError(RulesTasksStrings.AttachmentMetadataPropertyNotSpecified(value), base.Name));
                }
                else
                {
                    string[] source2 = array[1].Trim().Split(new char[]
                    {
                        ','
                    });
                    if (!source2.Any(new Func <string, bool>(string.IsNullOrWhiteSpace)))
                    {
                        i++;
                        continue;
                    }
                    errors.Add(new RulePhrase.RulePhraseValidationError(RulesTasksStrings.AttachmentMetadataParameterContainsEmptyWords(value), base.Name));
                }
                return;
            }
            base.ValidateRead(errors);
        }