Beispiel #1
0
        public Tags Add(string tagName)
        {
            _tagValidator.Validate(tagName);

            var tag = new Tags
            {
                Name = tagName
            };

            _tagRepository.Insert(tag);

            _tagRepository.Save();

            return(tag);
        }
Beispiel #2
0
        public TValue this[int index]
        {
            get
            {
                if (index < 0 || index >= _dict.Count)
                {
                    throw new System.IndexOutOfRangeException();
                }
                var key = _dict.Keys.Take(index + 1).Last();
                return(_dict[key]);
            }
            set
            {
                if (index < 0 || index >= _dict.Count)
                {
                    throw new System.IndexOutOfRangeException();
                }
                var key = _dict.Keys.Take(index + 1).Last();
                if (!_validator.Validate(key, value))
                {
                    throw new TaggedCollectionValidationException();
                }

                this[key] = value;
            }
        }
Beispiel #3
0
        public void Validate_ShouldSetTheRelatedTag()
        {
            var startTag = new TagInfo {
                TagName = "if"
            };
            var endTag = new TagInfo {
                TagName = "if"
            };

            _validator.Validate(new List <ITagInfo> {
                startTag
            }, new List <ITagInfo> {
                endTag
            });

            Same(startTag.RelatedTag, endTag);
            Same(endTag.RelatedTag, startTag);
        }
Beispiel #4
0
 public void ValidateTagName(string value) =>
 _target.Validate(value);