Ejemplo n.º 1
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (Authenticator.Current == null)
            {
                return(value);
            }

            if (parameter == null)
            {
                parameter = this.PropertyName;
            }

            if (value != null && parameter is string propertyName)
            {
                if (value is IDomainUserDescriptor descriptor)
                {
                    if (propertyName == IsOnline)
                    {
                        return(DomainUserDescriptorUtility.IsOnline(Authenticator.Current, descriptor));
                    }
                    else if (propertyName == HasChanges)
                    {
                        return(DomainUserDescriptorUtility.HasChanges(Authenticator.Current, descriptor));
                    }
                    else if (propertyName == IsOwner)
                    {
                        return(DomainUserDescriptorUtility.IsOwner(Authenticator.Current, descriptor));
                    }
                    else if (propertyName == CanWrite)
                    {
                        return(DomainUserDescriptorUtility.CanWrite(Authenticator.Current, descriptor));
                    }
                    else if (propertyName == CanRead)
                    {
                        return(DomainUserDescriptorUtility.CanRead(Authenticator.Current, descriptor));
                    }
                }
                else
                {
                    var prop = value.GetType().GetProperty(propertyName);
                    if (prop != null)
                    {
                        return(prop.GetValue(value));
                    }
                }
            }
            return(value);
        }
Ejemplo n.º 2
0
 public static bool CanKick(Authentication authentication, IDomainUserDescriptor descriptor)
 {
     if (authentication == null)
     {
         throw new ArgumentNullException(nameof(authentication));
     }
     if (descriptor == null)
     {
         throw new ArgumentNullException(nameof(descriptor));
     }
     if (DomainUserDescriptorUtility.IsOwner(authentication, descriptor) == true)
     {
         return(false);
     }
     return(authentication.Authority == Authority.Admin);
 }
Ejemplo n.º 3
0
 public static bool CanSendMessage(Authentication authentication, IDomainUserDescriptor descriptor)
 {
     if (authentication == null)
     {
         throw new ArgumentNullException(nameof(authentication));
     }
     if (descriptor == null)
     {
         throw new ArgumentNullException(nameof(descriptor));
     }
     if (DomainUserDescriptorUtility.IsOnline(authentication, descriptor) == false)
     {
         return(false);
     }
     return(authentication.ID != descriptor.DomainUserInfo.UserID);
 }