Exemplo n.º 1
0
        public LinkedPropertyDescriptor(CustomPropertyDescriptor propertyDescriptor, LinkedDescriptorContextItem contextItem)
            : base(propertyDescriptor.EditingContext, propertyDescriptor.Component, propertyDescriptor.Name
                   , PropertyWindowViewModelHelper.GetArrayFromCollection <Attribute>(propertyDescriptor.Attributes))
        {
            _wrappedCustomPropertyDescriptor = propertyDescriptor;
            _contextItem = contextItem;

            // Since we need to call the protected methods but we still want the methods to be remained protected in other cases, use the reflector to do so.
            _setEFElementValueMethod = typeof(CustomPropertyDescriptor).GetMethod(
                "SetEFElementValue", BindingFlags.Instance | BindingFlags.NonPublic);
            Debug.Assert(_setEFElementValueMethod != null, "Type CustomPropertyDescriptor does not have 'SetEFElementValue' method.");

            _resetEFElementValue = typeof(CustomPropertyDescriptor).GetMethod(
                "ResetEFElementValue", BindingFlags.Instance | BindingFlags.NonPublic);
            Debug.Assert(_resetEFElementValue != null, "Type CustomPropertyDescriptor does not have 'ResetEFElementValue' method.");
        }
        public ReflectedPropertyDescriptor(EditingContext editingContext, PropertyDescriptor reflectedPropDescriptor, object component)
            : base(
                editingContext, component, reflectedPropDescriptor.Name,
                PropertyWindowViewModelHelper.GetArrayFromCollection <Attribute>(reflectedPropDescriptor.Attributes))
        {
            _reflectedPropDescriptor = reflectedPropDescriptor;
            var propertyName = reflectedPropDescriptor.Name;

            _descriptionMethod = FindMethod(
                _reflectedPropDescriptor.ComponentType, "Description" + propertyName, Type.EmptyTypes, typeof(string), false);
            _isReadOnlyMethod = FindMethod(
                _reflectedPropDescriptor.ComponentType, "IsReadOnly" + propertyName, Type.EmptyTypes, typeof(bool), false);
            _isBrowsableMethod = FindMethod(
                _reflectedPropDescriptor.ComponentType, "IsBrowsable" + propertyName, Type.EmptyTypes, typeof(bool), false);
            _canResetMethod = FindMethod(
                _reflectedPropDescriptor.ComponentType, "CanReset" + propertyName, Type.EmptyTypes, typeof(bool), false);
        }