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); }
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); }