コード例 #1
0
 public UserCategoryDescriptor(Authentication authentication, IUserCategoryDescriptor descriptor, bool isSubscriptable, object owner)
     : base(authentication, descriptor.Target, descriptor, isSubscriptable)
 {
     this.category           = descriptor.Target;
     this.owner              = owner ?? this;
     this.usersReadonly      = new ReadOnlyObservableCollection <UserDescriptor>(this.users);
     this.categoriesReadonly = new ReadOnlyObservableCollection <UserCategoryDescriptor>(this.categories);
 }
コード例 #2
0
        public static async Task <bool> MoveAsync(Authentication authentication, IUserCategoryDescriptor descriptor)
        {
            var dialog = await MoveUserCategoryViewModel.CreateInstanceAsync(authentication, descriptor);

            if (dialog != null && await dialog.ShowDialogAsync() == true)
            {
                return(true);
            }
            return(false);
        }
コード例 #3
0
        public static Task <RenameCategoryViewModel> CreateInstanceAsync(Authentication authentication, IUserCategoryDescriptor descriptor)
        {
            if (authentication == null)
            {
                throw new ArgumentNullException(nameof(authentication));
            }
            if (descriptor == null)
            {
                throw new ArgumentNullException(nameof(descriptor));
            }

            if (descriptor.Target is IUserCategory category)
            {
                return(category.Dispatcher.InvokeAsync(() =>
                {
                    return new RenameCategoryViewModel(authentication, category);
                }));
            }
            else
            {
                throw new ArgumentException("Invalid Target of Descriptor", nameof(descriptor));
            }
        }
コード例 #4
0
        public static Task <MoveUserCategoryViewModel> CreateInstanceAsync(Authentication authentication, IUserCategoryDescriptor descriptor)
        {
            if (authentication == null)
            {
                throw new ArgumentNullException(nameof(authentication));
            }
            if (descriptor == null)
            {
                throw new ArgumentNullException(nameof(descriptor));
            }

            if (descriptor.Target is IUserCategory category)
            {
                return(category.Dispatcher.InvokeAsync(() =>
                {
                    var categories = category.GetService(typeof(IUserCategoryCollection)) as IUserCategoryCollection;
                    var targetPaths = categories.Select(item => item.Path).ToArray();
                    return new MoveUserCategoryViewModel(authentication, category, targetPaths);
                }));
            }
            else
            {
                throw new ArgumentException("Invalid Target of Descriptor", nameof(descriptor));
            }
        }
コード例 #5
0
ファイル: UserCategoryUtility.cs プロジェクト: teize001/Crema
        public static async Task <bool> DeleteAsync(Authentication authentication, IUserCategoryDescriptor descriptor)
        {
            var dialog = await DeleteUserCategoryViewModel.CreateInstanceAsync(authentication, descriptor);

            return(dialog?.ShowDialog() == true);
        }
コード例 #6
0
ファイル: UserCategoryUtility.cs プロジェクト: teize001/Crema
        public static async Task <string> NewFolderAsync(Authentication authentication, IUserCategoryDescriptor descriptor)
        {
            var dialog = await NewUserCategoryViewModel.CreateInstanceAsync(authentication, descriptor);

            if (dialog?.ShowDialog() == true)
            {
                return(dialog.CategoryName);
            }
            return(null);
        }
コード例 #7
0
ファイル: UserCategoryUtility.cs プロジェクト: teize001/Crema
 public static bool CanNewFolder(Authentication authentication, IUserCategoryDescriptor descriptor)
 {
     return(authentication.Authority == Authority.Admin);
 }
コード例 #8
0
 public static bool CanDelete(Authentication authentication, IUserCategoryDescriptor _)
 {
     return(authentication.Authority == Authority.Admin);
 }