コード例 #1
0
 public static bool CanSetPrivate(Authentication authentication, IAccessibleDescriptor descriptor)
 {
     if (descriptor.AccessInfo.IsPrivate == true && descriptor.AccessInfo.IsInherited == false)
     {
         return(false);
     }
     return(descriptor.AccessInfo.GetAccessType(authentication.ID) >= AccessType.Owner);
 }
コード例 #2
0
 public static bool IsAccessInherited(Authentication authentication, IAccessibleDescriptor descriptor)
 {
     if (authentication == null)
     {
         throw new ArgumentNullException(nameof(authentication));
     }
     if (descriptor == null)
     {
         throw new ArgumentNullException(nameof(descriptor));
     }
     return(descriptor.AccessInfo.IsInherited);
 }
コード例 #3
0
ファイル: AccessInfoViewModel.cs プロジェクト: teize001/Crema
 public override void SelectObject(object obj)
 {
     this.Detach();
     this.descriptor = obj as IAccessibleDescriptor;
     this.Attach();
 }
コード例 #4
0
        public static async Task <bool> SetAuthorityAsync(Authentication authentication, IAccessibleDescriptor descriptor)
        {
            var dialog = await AccessViewModel.CreateInstanceAsync(authentication, descriptor);

            return(dialog?.ShowDialog() == true);
        }
コード例 #5
0
        public static async Task <bool> SetPublicAsync(Authentication authentication, IAccessibleDescriptor descriptor)
        {
            if (descriptor.Target is IAccessible accessible)
            {
                var dispatcher = accessible is IDispatcherObject dispatcherObject ? dispatcherObject.Dispatcher : Application.Current.Dispatcher;
                try
                {
                    await dispatcher.InvokeAsync(() => accessible.SetPublic(authentication));

                    return(true);
                }
                catch (Exception e)
                {
                    AppMessageBox.ShowError(e);
                    return(false);
                }
            }
            else
            {
                throw new NotImplementedException();
            }
        }
コード例 #6
0
        public static async Task <AccessViewModel> CreateInstanceAsync(Authentication authentication, IAccessibleDescriptor descriptor)
        {
            if (authentication == null)
            {
                throw new ArgumentNullException(nameof(authentication));
            }
            if (descriptor == null)
            {
                throw new ArgumentNullException(nameof(descriptor));
            }

            if (descriptor.Target is IAccessible accessible)
            {
                if (accessible is IServiceProvider serviceProvider && serviceProvider.GetService(typeof(IUserCategoryCollection)) is IUserCategoryCollection userCategoryCollection)
                {
                    var viewModel = await userCategoryCollection.Dispatcher.InvokeAsync(() => new UserCategoryTreeViewItemViewModel(authentication, userCategoryCollection.Root));

                    return(await CreateInstanceAsync(authentication, descriptor, viewModel));
                }
                throw new NotImplementedException();
            }
            else
            {
                throw new ArgumentException("Invalid Target of Descriptor", nameof(descriptor));
            }
        }
コード例 #7
0
        public static async Task <AccessViewModel> CreateInstanceAsync(Authentication authentication, IAccessibleDescriptor descriptor, UserCategoryTreeViewItemViewModel userItem)
        {
            if (authentication == null)
            {
                throw new ArgumentNullException(nameof(authentication));
            }
            if (descriptor == null)
            {
                throw new ArgumentNullException(nameof(descriptor));
            }
            if (userItem == null)
            {
                throw new ArgumentNullException(nameof(userItem));
            }

            if (descriptor.Target is IAccessible accessible && accessible is IDispatcherObject dispatcherObject)
            {
                return(await dispatcherObject.Dispatcher.InvokeAsync(() =>
                {
                    return new AccessViewModel(authentication, accessible, userItem);
                }));
            }
            throw new NotImplementedException();
        }
コード例 #8
0
        public static async Task <bool> SetPublicAsync(Authentication authentication, IAccessibleDescriptor descriptor)
        {
            if (descriptor.Target is IAccessible accessible)
            {
                try
                {
                    await accessible.SetPublicAsync(authentication);

                    return(true);
                }
                catch (Exception e)
                {
                    await AppMessageBox.ShowErrorAsync(e);

                    return(false);
                }
            }
            else
            {
                throw new NotImplementedException();
            }
        }