예제 #1
0
        public void ValidateRename(string newName)
        {
            if (newName == null)
            {
                throw new ArgumentNullException(nameof(newName));
            }
            if (this.ItemAttributes.HasFlag(ItemAttributes.UniqueName) == true)
            {
                throw new ArgumentException(Resources.Exception_UniqueObjectCannotRename);
            }
            if (NameValidator.VerifyName(newName) == false)
            {
                throw new ArgumentException(string.Format(Resources.Exception_InvalidName_Format, newName), nameof(newName));
            }

            if (this.Container != null)
            {
                var newPath = CategoryBase <_I, _C, _IC, _CC, _CT> .CreatePath(newName, this.Parent);

                if (this.Container.Contains(newPath) == true && this.Container[newPath] != this)
                {
                    throw new ArgumentException(string.Format(Resources.Exception_AlreadyExistedItem_Format, newName), nameof(newName));
                }
            }

            var parent = this.parent;

            if (parent != null)
            {
                if (parent.Categories.ContainsKey(newName) == true)
                {
                    throw new ArgumentException(string.Format(Resources.Exception_AlreadyExistedItem_Format, newName));
                }
                if (parent.items.ContainsKey(newName) == true)
                {
                    throw new ArgumentException(string.Format(Resources.Exception_AlreadyExistedItem_Format, newName));
                }
                this.ValidateMove(parent);
            }
        }
예제 #2
0
 public ChildCollection(CategoryBase <_I, _C, _IC, _CC, _CT> category)
 {
     this.category = category;
 }