/// <inheritdoc cref="Create{TSource}(TSource,string)"/>
        /// <param name="targetInstance"><inheritdoc cref="targetInstance"/></param>
        /// <param name="property">The <see cref="PropertyInfo"/> to use when creating a new instance of <see cref="PropertyWrapper{TValue}"/>
        /// <remarks>The <see cref="PropertyWrapper{TValue}"/> will be created with getter and setter methods extracted from this <see cref="PropertyInfo"/></remarks>
        /// </param>
        public static PropertyWrapper <TValue> Create <TSource>(TSource targetInstance, PropertyInfo property)
            where TSource : IBindingSource
        {
            var result = new PropertyWrapper <TValue>(property.Name);

            result.CreateDelegates(targetInstance, property);
            return(result);
        }
Example #2
0
        public IBinding <TValue> Bind <TTarget>(TTarget target, string propertyName) where TTarget : IBindingSource
        {
            if (targets.ContainsKey(target))
            {
                return(this);
            }
            var wrapper = PropertyWrapper <TValue> .Create(target, propertyName); //new PropertyWrapper<TValue>(target, propertyName);

            targets.Add(target, wrapper);
            target.AddPropertyChangedHandler <TValue>(propertyName, OnPropertyChanged);
            return(this);
        }