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 IDomainMemberDescriptor descriptor) { if (propertyName == IsOnline) { return(DomainMemberDescriptorUtility.IsOnline(Authenticator.Current, descriptor)); } else if (propertyName == HasChanges) { throw new NotImplementedException(); //return DomainMemberDescriptorUtility.HasChanges(Authenticator.Current, descriptor); } else if (propertyName == IsOwner) { return(DomainMemberDescriptorUtility.IsOwner(Authenticator.Current, descriptor)); } else if (propertyName == CanWrite) { return(DomainMemberDescriptorUtility.CanWrite(Authenticator.Current, descriptor)); } else if (propertyName == CanRead) { return(DomainMemberDescriptorUtility.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, 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); }
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); }