Beispiel #1
0
 public static bool CanNewFolder(Authentication authentication, ITypeCategoryDescriptor descriptor)
 {
     if (descriptor is IPermissionDescriptor permissionDescriptor)
     {
         return(permissionDescriptor.AccessType >= AccessType.Master);
     }
     return(false);
 }
Beispiel #2
0
 public static bool CanViewLog(Authentication authentication, ITypeCategoryDescriptor descriptor)
 {
     if (descriptor is IPermissionDescriptor permissionDescriptor)
     {
         return(permissionDescriptor.AccessType >= AccessType.Guest);
     }
     return(false);
 }
Beispiel #3
0
        public static async Task <bool> DeleteAsync(Authentication authentication, ITypeCategoryDescriptor descriptor)
        {
            var dialog = await DeleteTypeCategoryViewModel.CreateInstanceAsync(authentication, descriptor);

            if (dialog != null && await dialog.ShowDialogAsync() == true)
            {
                return(true);
            }
            return(false);
        }
Beispiel #4
0
        public static async Task <bool> FindAsync(Authentication authentication, ITypeCategoryDescriptor descriptor)
        {
            if (authentication == null)
            {
                throw new ArgumentNullException(nameof(authentication));
            }
            if (descriptor == null)
            {
                throw new ArgumentNullException(nameof(descriptor));
            }

            if (descriptor.Target is ITypeCategory category && category.GetService(typeof(TypeDocumentServiceViewModel)) is TypeDocumentServiceViewModel documentService)
            {
                documentService.AddFinder(authentication, descriptor.Path);
                return(await Task.Run(() => true));
            }
Beispiel #5
0
        public static async Task <bool> MoveAsync(Authentication authentication, ITypeCategoryDescriptor descriptor)
        {
            var comment = await LockAsync(authentication, descriptor, nameof(ITypeCategory.MoveAsync));

            if (comment == null)
            {
                return(false);
            }
            var dialog = await MoveTypeCategoryViewModel.CreateInstanceAsync(authentication, descriptor);

            var dialogResult = await ShowDialogAsync(dialog);

            await UnlockAsync(authentication, descriptor, comment);

            return(dialogResult);
        }
Beispiel #6
0
        public static async Task <bool> RenameAsync(Authentication authentication, ITypeCategoryDescriptor descriptor)
        {
            var comment = await LockAsync(authentication, descriptor, nameof(ITypeCategory.Rename));

            if (comment == null)
            {
                return(false);
            }

            var dialog = await RenameCategoryViewModel.CreateInstanceAsync(authentication, descriptor);

            dialog?.ShowDialog();

            await UnlockAsync(authentication, descriptor, comment);

            return(dialog?.DialogResult == true);
        }
        public static Task <NewTypeCategoryViewModel> CreateInstanceAsync(Authentication authentication, ITypeCategoryDescriptor descriptor)
        {
            if (authentication == null)
            {
                throw new ArgumentNullException(nameof(authentication));
            }
            if (descriptor == null)
            {
                throw new ArgumentNullException(nameof(descriptor));
            }

            if (descriptor.Target is ITypeCategory category)
            {
                return(category.Dispatcher.InvokeAsync(() =>
                {
                    return new NewTypeCategoryViewModel(authentication, category);
                }));
            }
            else
            {
                throw new ArgumentException("Invalid Target of Descriptor", nameof(descriptor));
            }
        }
Beispiel #8
0
        public static async Task <string> NewTypeAsync(Authentication authentication, ITypeCategoryDescriptor descriptor)
        {
            var dialog = await NewTypeViewModel.CreateInstanceAsync(authentication, descriptor);

            if (dialog?.ShowDialog() == true)
            {
                return(dialog.TypeName);
            }
            return(null);
        }
Beispiel #9
0
        public static async Task <bool> DeleteAsync(Authentication authentication, ITypeCategoryDescriptor descriptor)
        {
            var dialog = await DeleteTypeCategoryViewModel.CreateInstanceAsync(authentication, descriptor);

            return(dialog?.ShowDialog() == true);
        }
        public static Task <MoveTypeCategoryViewModel> CreateInstanceAsync(Authentication authentication, ITypeCategoryDescriptor descriptor)
        {
            if (authentication == null)
            {
                throw new ArgumentNullException(nameof(authentication));
            }
            if (descriptor == null)
            {
                throw new ArgumentNullException(nameof(descriptor));
            }

            if (descriptor.Target is ITypeCategory category)
            {
                return(category.Dispatcher.InvokeAsync(() =>
                {
                    var categories = category.GetService(typeof(ITypeCategoryCollection)) as ITypeCategoryCollection;
                    var targetPaths = categories.Select(item => item.Path).ToArray();
                    return new MoveTypeCategoryViewModel(authentication, category, targetPaths);
                }));
            }
            else
            {
                throw new ArgumentException("Invalid Target of Descriptor", nameof(descriptor));
            }
        }
Beispiel #11
0
 public TypeCategoryDescriptor(Authentication authentication, ITypeCategoryDescriptor descriptor, bool isSubscriptable, object owner)
     : base(authentication, descriptor.Target, descriptor, isSubscriptable)
 {
     this.category = descriptor.Target;
     this.owner    = owner ?? this;
 }