Ejemplo n.º 1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="BindingMemberInfo" /> class.
        /// </summary>
        public BindingMemberInfo([NotNull] string path, [NotNull] PropertyInfo property, Type sourceType)
            : this(path, BindingMemberType.Property, property.PropertyType)
        {
            _member = property;
            var method = property.GetGetMethod(true);

            if (method == null)
            {
                _getValueAccessorSingle = NotSupportedGetter;
                _canRead = false;
            }
            else
            {
                _getValueAccessorSingle = property.GetGetPropertyAccessor(method, path);
                _canRead = true;
            }
            method = property.GetSetMethod(true);
            if (method == null)
            {
                _setValueAccessorSingle = NotSupportedSetter;
                _canWrite = false;
            }
            else
            {
                _setValueAccessorSingleAction = property.GetSetPropertyAccessor(method, path);
                _canWrite = true;
            }
            _isSingleParameter = true;

            _memberEvent = BindingExtensions.TryFindMemberChangeEvent(BindingServiceProvider.MemberProvider, sourceType, property.Name);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Gets an instance of <see cref="IBindingMemberInfo" /> using the source type and binding path.
        /// </summary>
        /// <param name="sourceType">The specified source type.</param>
        /// <param name="path">The specified binding path.</param>
        /// <returns>The instance of <see cref="IBindingMemberInfo" />.</returns>
        protected override IBindingMemberInfo GetExplicitBindingMember(Type sourceType, string path)
        {
            if (typeof(DependencyObject).IsAssignableFrom(sourceType))
            {
                var property = GetDependencyProperty(sourceType, path);
                if (property != null)
                {
                    IBindingMemberInfo changeEvent = BindingExtensions.TryFindMemberChangeEvent(this, sourceType, path);
#if WPF
                    return(new DependencyPropertyBindingMember(property, path, property.PropertyType, property.ReadOnly, sourceType.GetProperty(path), changeEvent));
#else
                    var  member   = sourceType.GetPropertyEx(path);
                    Type type     = typeof(object);
                    bool readOnly = false;
                    if (member != null)
                    {
                        type     = member.PropertyType;
                        readOnly = !member.CanWrite;
                    }
                    return(new DependencyPropertyBindingMember(property, path, type, readOnly, member, changeEvent));
#endif
                }
            }
            return(base.GetExplicitBindingMember(sourceType, path));
        }
Ejemplo n.º 3
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="BindingMemberInfo" /> class.
 /// </summary>
 public BindingMemberInfo([NotNull] string path, [NotNull] FieldInfo field, Type sourceType)
     : this(path, BindingMemberType.Field, field.FieldType)
 {
     _member = field;
     _getValueAccessorSingle       = ServiceProvider.ReflectionManager.GetMemberGetter <object>(field);
     _setValueAccessorSingleAction = ServiceProvider.ReflectionManager.GetMemberSetter <object>(field);
     _canRead           = true;
     _canWrite          = true;
     _isSingleParameter = true;
     _memberEvent       = BindingExtensions.TryFindMemberChangeEvent(BindingServiceProvider.MemberProvider, sourceType, field.Name);
 }