Пример #1
0
            /// <summary>
            ///     Initializes a new instance of the <see cref="NotifyPropertyObservation"/> class.
            /// </summary>
            /// <param name="data">
            ///     The data.
            /// </param>
            /// <param name="property">
            ///     The property.
            /// </param>
            /// <param name="childProperty">
            ///     The child property.
            /// </param>
            public NotifyPropertyObservation(BindContext data, string property, string childProperty)
            {
                this.data = data;
                if (!string.IsNullOrEmpty(childProperty))
                {
                    this.child = data.CreatePropertyObservation(childProperty);
                }

                this.Property = property;
            }
Пример #2
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="BindContext"/> class.
        /// </summary>
        /// <param name="target">
        ///     The target.
        /// </param>
        /// <param name="targetProperty">
        ///     The target property.
        /// </param>
        public BindContext(object target, string targetProperty)
        {
            this.OriginalSource      = target;
            this.propertyObservation = this.CreatePropertyObservation(targetProperty);

            if (this.propertyObservation != null)
            {
                this.propertyObservation.Source = target;
                this.Property = this.Tail.Property;
            }
            else
            {
                this.Source = target;
            }
        }
Пример #3
0
        /// <summary>
        ///     Creates property observation.
        /// </summary>
        /// <param name="targetProperty">
        ///     The target property.
        /// </param>
        /// <returns>
        ///     The <see cref="NotifyPropertyObservation"/>.
        /// </returns>
        private NotifyPropertyObservation CreatePropertyObservation(string targetProperty)
        {
            if (targetProperty == null)
            {
                return(null);
            }

            int  indexerIndex = targetProperty.IndexOf(BindingManager.IndexerLeftMark, StringComparison.Ordinal);
            int  pointIndex   = targetProperty.IndexOf(".", StringComparison.Ordinal);
            bool isIndex      = indexerIndex == 0;

            string property      = targetProperty;
            string childProperty = null;

            if (isIndex)
            {
                // Index Property
                int rightIndex = property.IndexOf(BindingManager.IndexerRightMark, StringComparison.Ordinal);
                property      = property.Substring(1, rightIndex - 1);
                childProperty =
                    targetProperty.Substring(rightIndex + 1, targetProperty.Length - rightIndex - 1).TrimStart('.');
            }
            else if (indexerIndex + pointIndex > -1)
            {
                if (indexerIndex > -1 && (pointIndex == -1 || indexerIndex < pointIndex))
                {
                    property      = targetProperty.Substring(0, indexerIndex);
                    childProperty = targetProperty.Substring(indexerIndex, targetProperty.Length - indexerIndex);
                }
                else if (pointIndex > -1)
                {
                    property      = targetProperty.Substring(0, pointIndex);
                    childProperty = targetProperty.Substring(pointIndex + 1, targetProperty.Length - pointIndex - 1);
                }
            }

            NotifyPropertyObservation observation = isIndex
                                                                ? new NotifyIndexPropertyObservation(
                this,
                property,
                childProperty)
                                                                : new NotifyPropertyObservation(
                this,
                property,
                childProperty);

            return(observation);
        }
Пример #4
0
            /// <summary>
            ///     Initializes a new instance of the <see cref="NotifyPropertyObservation"/> class.
            /// </summary>
            /// <param name="data">
            ///     The data.
            /// </param>
            /// <param name="property">
            ///     The property.
            /// </param>
            /// <param name="childProperty">
            ///     The child property.
            /// </param>
            public NotifyPropertyObservation(BindContext data, string property, string childProperty)
            {
                this.data = data;
                if (!string.IsNullOrEmpty(childProperty))
                {
                    this.child = data.CreatePropertyObservation(childProperty);
                }

                this.Property = property;
            }
Пример #5
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="BindContext"/> class.
        /// </summary>
        /// <param name="target">
        ///     The target.
        /// </param>
        /// <param name="targetProperty">
        ///     The target property.
        /// </param>
        public BindContext(object target, string targetProperty)
        {
            this.OriginalSource = target;
            this.propertyObservation = this.CreatePropertyObservation(targetProperty);

            if (this.propertyObservation != null)
            {
                this.propertyObservation.Source = target;
                this.Property = this.Tail.Property;
            }
            else
            {
                this.Source = target;
            }
        }