示例#1
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (parameter == null)
            {
                parameter = this.PropertyName;
            }

            if (value != null && parameter is string propertyName)
            {
                if (value is ILockableDescriptor descriptor)
                {
                    if (propertyName == IsLocked)
                    {
                        return(LockableDescriptorUtility.IsLocked(Authenticator.Current, descriptor));
                    }
                    else if (propertyName == IsLockInherited)
                    {
                        return(LockableDescriptorUtility.IsLockInherited(Authenticator.Current, descriptor));
                    }
                    else if (propertyName == IsLockOwner && Authenticator.Current != null)
                    {
                        return(LockableDescriptorUtility.IsLockOwner(Authenticator.Current, descriptor));
                    }
                }
                else
                {
                    var prop = value.GetType().GetProperty(propertyName);
                    if (prop != null)
                    {
                        return(prop.GetValue(value));
                    }
                }
            }
            return(value);
        }
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     if (value is ILockableDescriptor descriptor)
     {
         return(LockableDescriptorUtility.IsLockOwner(Authenticator.Current, descriptor));
     }
     return(false);
 }