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 ITableDescriptor descriptor)
                {
                    if (propertyName == IsBeingEdited)
                    {
                        return(TableDescriptorUtility.IsBeingEdited(Authenticator.Current, descriptor));
                    }
                    else if (propertyName == IsContentEditor)
                    {
                        throw new NotImplementedException();
                        //return TableDescriptorUtility.IsContentEditor(Authenticator.Current, descriptor);
                    }
                    else if (propertyName == IsBeingSetup)
                    {
                        return(TableDescriptorUtility.IsBeingSetup(Authenticator.Current, descriptor));
                    }
                    else if (propertyName == IsTemplateEditor)
                    {
                        throw new NotImplementedException();
                        //return TableDescriptorUtility.IsTemplateEditor(Authenticator.Current, descriptor);
                    }
                    else if (propertyName == IsInherited)
                    {
                        return(TableDescriptorUtility.IsInherited(Authenticator.Current, descriptor));
                    }
                    else if (propertyName == IsBaseTemplate)
                    {
                        return(TableDescriptorUtility.IsBaseTemplate(Authenticator.Current, descriptor));
                    }
                }
                else
                {
                    var prop = value.GetType().GetProperty(propertyName);
                    if (prop != null)
                    {
                        return(prop.GetValue(value));
                    }
                }
            }
            return(value);
        }
 protected override bool OnCanExecute(object parameter)
 {
     if (parameter is ITableDescriptor descriptor)
     {
         if (TableDescriptorUtility.IsBeingEdited(this.authenticator, descriptor) == false)
         {
             return(false);
         }
         return(descriptor.IsContentOwner == true || this.authenticator.Authority == Authority.Admin);
     }
     return(false);
 }