Пример #1
0
        public static async Task <bool> KickAsync(Authentication authentication, IDomainMemberDescriptor descriptor)
        {
            var dialog = await KickEditorViewModel.CreateInstanceAsync(authentication, descriptor);

            if (dialog != null)
            {
                return(await dialog.ShowDialogAsync() == true);
            }
            return(false);
        }
Пример #2
0
 public static bool CanWrite(Authentication authentication, IDomainMemberDescriptor descriptor)
 {
     if (authentication == null)
     {
         throw new ArgumentNullException(nameof(authentication));
     }
     if (descriptor == null)
     {
         throw new ArgumentNullException(nameof(descriptor));
     }
     return(descriptor.DomainMemberInfo.AccessType.HasFlag(DomainAccessType.ReadWrite));
 }
Пример #3
0
 public static bool IsOwner(Authentication authentication, IDomainMemberDescriptor descriptor)
 {
     if (authentication == null)
     {
         throw new ArgumentNullException(nameof(authentication));
     }
     if (descriptor == null)
     {
         throw new ArgumentNullException(nameof(descriptor));
     }
     return(descriptor.DomainMemberState.HasFlag(DomainMemberState.IsOwner));
 }
Пример #4
0
 public static bool IsAdmin(Authentication authentication, IDomainMemberDescriptor descriptor)
 {
     if (authentication == null)
     {
         throw new ArgumentNullException(nameof(authentication));
     }
     if (descriptor == null)
     {
         throw new ArgumentNullException(nameof(descriptor));
     }
     return(authentication.Authority == Authority.Admin);
 }
        public DomainMemberDescriptor(Authentication authentication, IDomainMemberDescriptor descriptor, DescriptorTypes descriptorTypes, object owner)
            : base(authentication, descriptor.Target, descriptorTypes)
        {
            this.domainMember = descriptor.Target;
            this.Owner        = owner ?? this;
            this.domainMember.Dispatcher.VerifyAccess();
            this.domainMemberInfo  = domainMember.DomainMemberInfo;
            this.DomainMemberState = domainMember.DomainMemberState;

            if (this.descriptorTypes.HasFlag(DescriptorTypes.IsSubscriptable) == true && descriptor is INotifyPropertyChanged obj)
            {
                obj.PropertyChanged += Descriptor_PropertyChanged;
            }
        }
Пример #6
0
 public static bool CanKick(Authentication authentication, IDomainMemberDescriptor descriptor)
 {
     if (authentication == null)
     {
         throw new ArgumentNullException(nameof(authentication));
     }
     if (descriptor == null)
     {
         throw new ArgumentNullException(nameof(descriptor));
     }
     if (DomainMemberDescriptorUtility.IsOwner(authentication, descriptor) == true)
     {
         return(false);
     }
     return(authentication.Authority == Authority.Admin);
 }
Пример #7
0
 public static bool CanSendMessage(Authentication authentication, IDomainMemberDescriptor descriptor)
 {
     if (authentication == null)
     {
         throw new ArgumentNullException(nameof(authentication));
     }
     if (descriptor == null)
     {
         throw new ArgumentNullException(nameof(descriptor));
     }
     if (DomainMemberDescriptorUtility.IsOnline(authentication, descriptor) == false)
     {
         return(false);
     }
     return(authentication.ID != descriptor.DomainMemberInfo.ID);
 }
Пример #8
0
        public static async Task <bool> SetOwnerAsync(Authentication authentication, IDomainMemberDescriptor descriptor)
        {
            if (descriptor.Target is IDomainMember domainMember)
            {
                try
                {
                    await domainMember.SetOwnerAsync(authentication);

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

                    return(false);
                }
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Пример #9
0
        public static Task <KickEditorViewModel> CreateInstanceAsync(Authentication authentication, IDomainMemberDescriptor descriptor)
        {
            if (authentication == null)
            {
                throw new ArgumentNullException(nameof(authentication));
            }
            if (descriptor == null)
            {
                throw new ArgumentNullException(nameof(descriptor));
            }

            if (descriptor.Target is IDomainMember domainMember)
            {
                return(domainMember.Dispatcher.InvokeAsync(() =>
                {
                    return new KickEditorViewModel(authentication, domainMember);
                }));
            }
            else
            {
                throw new ArgumentException("Invalid Target of Descriptor", nameof(descriptor));
            }
        }
 public DomainMemberListItemBase(Authentication authentication, IDomainMemberDescriptor descriptor, bool IsSubscriptable, object owner)
     : base(authentication, new DomainMemberDescriptor(authentication, descriptor, IsSubscriptable == true ? DescriptorTypes.All : DescriptorTypes.IsRecursive, owner), owner)
 {
 }
Пример #11
0
        public static async Task <bool> SendMessageAsync(Authentication authentication, IDomainMemberDescriptor descriptor)
        {
            if (descriptor.Target is IDomainMember domainMember)
            {
                if (domainMember.GetService(typeof(IUserContext)) is IUserContext userContext)
                {
                    var userCollection = userContext.GetService(typeof(IUserCollection)) as IUserCollection;
                    var user           = await userContext.Dispatcher.InvokeAsync(() => userCollection[descriptor.DomainMemberInfo.ID]);

                    var dialog = await user.Dispatcher.InvokeAsync(() => new SendMessageViewModel(authentication, user));

                    if (dialog != null)
                    {
                        return(await dialog.ShowDialogAsync() == true);
                    }
                    return(false);
                }
                return(false);
            }
            else
            {
                throw new NotImplementedException();
            }
        }