Esempio n. 1
0
        public _C Prepare(string categoryPath)
        {
            var categoryName = new CategoryName(categoryPath);

            if (this.ContainsKey(categoryName.ParentPath) == false)
            {
                this.Prepare(categoryName.ParentPath);
            }
            if (this.ContainsKey(categoryPath) == false)
            {
                return(this.BaseAddNew(categoryName.Name, categoryName.ParentPath, null));
            }
            return(this[categoryPath]);
        }
Esempio n. 2
0
        public virtual void ValidateAddNew(string name, string parentCategoryPath, object validation, params object[] args)
        {
            if (this.Contains(parentCategoryPath) == false)
            {
                throw new ArgumentException(string.Format(Resources.Exception_NotFoundFolder_Format, parentCategoryPath), nameof(parentCategoryPath));
            }

            var parent = this[parentCategoryPath];

            if (parent.Categories.ContainsKey(name) == true)
            {
                throw new ArgumentException(Resources.Exception_SameFolderInParent);
            }

            if (parent.Items.ContainsKey(name) == true)
            {
                throw new ArgumentException(Resources.Exception_SameItemInParent);
            }

            if (this.Contains(CategoryName.MakePath(parentCategoryPath, name)) == true)
            {
                throw new ArgumentException(string.Format(Resources.Exception_AlreadyExistedItem_Format, name), nameof(name));
            }
        }