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); }
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); }
public override void SelectObject(object obj) { this.Detach(); this.descriptor = obj as IAccessibleDescriptor; this.Attach(); }
public static async Task <bool> SetAuthorityAsync(Authentication authentication, IAccessibleDescriptor descriptor) { var dialog = await AccessViewModel.CreateInstanceAsync(authentication, descriptor); return(dialog?.ShowDialog() == true); }
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(); } }
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)); } }
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(); }
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(); } }