Esempio 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);
        }
Esempio n. 2
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);
 }