public void Rename(ITypeCategory category, TaskContext context) { category.Dispatcher.Invoke(() => { var categoryName = RandomUtility.NextIdentifier(); if (Verify() == false) { return; } category.Rename(context.Authentication, categoryName); }); bool Verify() { if (context.AllowException == true) { return(true); } if (category.Parent == null) { return(false); } return(true); } }
public static void RenameTest(this ITypeCategory category, Authentication authentication) { Assert.AreNotEqual(null, category.Parent); var parent = category.Parent; var newName = NameUtility.GenerateNewName(RandomUtility.NextIdentifier(), parent.Categories.Select(item => item.Name)); category.Rename(authentication, newName); }
public void Rename() { category.Rename(authentication, RandomUtility.NextIdentifier()); }
private void MoveTypeCategory(Authentication authentication, ITypeCategory sourceCategory, string newPath) { var destPath = new DataBasePath(newPath); var destObject = this.GetObject(authentication, destPath.Path); this.CremaHost.Dispatcher.Invoke(MoveTypeCategory); void MoveTypeCategory() { var dataBase = sourceCategory.GetService(typeof(IDataBase)) as IDataBase; var types = sourceCategory.GetService(typeof(ITypeCollection)) as ITypeCollection; if (destPath.DataBaseName != dataBase.Name) { throw new InvalidOperationException($"cannot move to : {destPath}"); } if (destPath.Context != CremaSchema.TypeDirectory) { throw new InvalidOperationException($"cannot move to : {destPath}"); } if (destObject is IType) { throw new InvalidOperationException($"cannot move to : {destPath}"); } using (DataBaseUsing.Set(dataBase, authentication)) { if (destObject is ITypeCategory destCategory) { if (sourceCategory.Parent != destCategory) { sourceCategory.Move(authentication, destCategory.Path); } } else { if (NameValidator.VerifyCategoryPath(destPath.ItemPath) == true) { throw new InvalidOperationException($"cannot move to : {destPath}"); } var itemName = new ItemName(destPath.ItemPath); var categories = sourceCategory.GetService(typeof(ITypeCategoryCollection)) as ITypeCategoryCollection; if (categories.Contains(itemName.CategoryPath) == false) { throw new InvalidOperationException($"cannot move to : {destPath}"); } if (sourceCategory.Name != itemName.Name && types.Contains(itemName.Name) == true) { throw new InvalidOperationException($"cannot move to : {destPath}"); } if (sourceCategory.Parent.Path != itemName.CategoryPath) { sourceCategory.Move(authentication, itemName.CategoryPath); } if (sourceCategory.Name != itemName.Name) { sourceCategory.Rename(authentication, itemName.Name); } } } } }