Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DependencyBoundValue{TDependency}"/> class.
        /// </summary>
        /// <param name="value">The dependency property value which created this object.</param>
        /// <param name="expressionType">The type of the bound expression.</param>
        /// <param name="dataSourceType">The type of the data source.</param>
        /// <param name="expression">The binding expression.</param>
        public DependencyBoundValue(IDependencyPropertyValue value, Type expressionType, Type dataSourceType, String expression)
        {
            this.dependencyValue = value;
            this.getter          = (DataBindingGetter <T>)BindingExpressions.CreateBindingGetter(expressionType, dataSourceType, expression);
            this.setter          = (DataBindingSetter <T>)BindingExpressions.CreateBindingSetter(expressionType, dataSourceType, expression);
            this.comparer        = BindingExpressions.GetComparisonFunction(expressionType);
            this.cachedValue     = GetUnderlyingValue();
            this.dpropReference  = BindingExpressions.GetSimpleDependencyProperty(dataSourceType, expression);

            if (dpropReference != null)
            {
                var dataSource = value.Owner.DependencyDataSource;
                if (dataSource != null)
                {
                    HookDependencyProperty(dataSource);
                }
            }
        }