/// <summary>
        /// Creates an appropriate property monitor for the remaining property path string on the target object.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="propertyPath">The property path.</param>
        /// <param name="callback">The callback.</param>
        /// <param name="pathNavigator">The path navigator.</param>
        /// <returns>
        /// An appropriate <see cref="IToken"/> for the property.
        /// </returns>
        public IToken ParseNext(object target, string propertyPath, Action<object, string> callback, IPathNavigator pathNavigator)
        {
            IToken result = null;
            #if SILVERLIGHT
            if (target is DependencyObject)
            {
                string propertyName = propertyPath;
                string remainingPath = null;
                int dotIndex = propertyPath.IndexOf('.');
                if (dotIndex >= 0)
                {
                    propertyName = propertyPath.Substring(0, dotIndex);
                    remainingPath = propertyPath.Substring(dotIndex + 1);
                }

                DependencyObject dependencyObject = (DependencyObject)target;
                if (dependencyObject != null)
                {
                    FieldInfo field = dependencyObject.GetType().GetField(propertyName + "Property", BindingFlags.Public | BindingFlags.Static);
                    if (field != null)
                    {
                        DependencyProperty dependencyProperty = (DependencyProperty)field.GetValue(null);
                        if (dependencyProperty != null)
                        {
                            result = new SilverlightMemberToken(dependencyObject, dependencyProperty, propertyName, remainingPath, callback, pathNavigator);
                        }
                    }
                }
            }
            #endif
            return result;
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MemberToken"/> class.
 /// </summary>
 /// <param name="currentTarget">The current target.</param>
 /// <param name="propertyName">Name of the property.</param>
 /// <param name="remainingPath">The remaining path.</param>
 /// <param name="changeDetectedCallback">The change detected callback.</param>
 /// <param name="traverser">The traverser.</param>
 public MemberToken(object currentTarget, string propertyName, string remainingPath, Action<object, string> changeDetectedCallback, IPathNavigator traverser)
 {
     _changeDetectedCallback = changeDetectedCallback;
     _remainingPath = remainingPath;
     _propertyName = propertyName;
     _pathNavigator = traverser;
 }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WpfMemberToken"/> class.
        /// </summary>
        /// <param name="objectToObserve">The object to observe.</param>
        /// <param name="dependencyProperty">The dependency property.</param>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="remainingPath">The remaining path.</param>
        /// <param name="callback">The callback.</param>
        /// <param name="pathNavigator">The path navigator.</param>
        public WpfMemberToken(DependencyObject objectToObserve, DependencyProperty dependencyProperty, string propertyName, string remainingPath, Action<object, string> callback, IPathNavigator pathNavigator)
            : base(objectToObserve, propertyName, remainingPath, callback, pathNavigator)
        {
            _dependencyProperty = dependencyProperty;

            AcquireTarget(objectToObserve);
        }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MemberToken"/> class.
 /// </summary>
 /// <param name="currentTarget">The current target.</param>
 /// <param name="propertyName">Name of the property.</param>
 /// <param name="remainingPath">The remaining path.</param>
 /// <param name="changeDetectedCallback">The change detected callback.</param>
 /// <param name="traverser">The traverser.</param>
 public MemberToken(object currentTarget, string propertyName, string remainingPath, Action <object, string> changeDetectedCallback, IPathNavigator traverser)
 {
     _changeDetectedCallback = changeDetectedCallback;
     _remainingPath          = remainingPath;
     _propertyName           = propertyName;
     _pathNavigator          = traverser;
 }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WindowsFormsMemberToken"/> class.
        /// </summary>
        /// <param name="objectToObserve">The object to observe.</param>
        /// <param name="propertyName">The property path.</param>
        /// <param name="remainingPath">The remaining path.</param>
        /// <param name="callback">The callback.</param>
        /// <param name="pathNavigator">The path navigator.</param>
        public WindowsFormsMemberToken(object objectToObserve, string propertyName, string remainingPath, Action<object, string> callback, IPathNavigator pathNavigator)
            : base(objectToObserve, propertyName, remainingPath, callback, pathNavigator)
        {
            _actualHandler = CurrentTarget_PropertyChanged;

            AcquireTarget(objectToObserve);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SilverlightMemberToken"/> class.
        /// </summary>
        /// <param name="objectToObserve">The object to observe.</param>
        /// <param name="dependencyProperty">The dependency property.</param>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="remainingPath">The remaining path.</param>
        /// <param name="callback">The callback.</param>
        /// <param name="pathNavigator">The path navigator.</param>
        public SilverlightMemberToken(DependencyObject objectToObserve, DependencyProperty dependencyProperty, string propertyName, string remainingPath, Action<object, string> callback, IPathNavigator pathNavigator)
            : base(objectToObserve, propertyName, remainingPath, callback, pathNavigator)
        {
            _dependencyProperty = dependencyProperty;
            _actualHandler = CurrentTarget_PropertyChanged;

            AcquireTarget(objectToObserve);
        }
 public ItemDependency(string propertyPath, IBindableCollection <TElement> sourceElements, IPathNavigator pathNavigator)
 {
     _pathNavigator          = pathNavigator;
     _sourceElementObservers = new Dictionary <TElement, IToken>();
     _propertyPath           = propertyPath;
     _sourceElements         = sourceElements;
     _actioner = new ElementActioner <TElement>(sourceElements, AddItem, RemoveItem, sourceElements.Dispatcher);
 }
Example #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ClrMemberToken"/> class.
        /// </summary>
        /// <param name="objectToObserve">The object to observe.</param>
        /// <param name="propertyName">The property path.</param>
        /// <param name="remainingPath">The remaining path.</param>
        /// <param name="callback">The callback.</param>
        /// <param name="pathNavigator">The path navigator.</param>
        public ClrMemberToken(object objectToObserve, string propertyName, string remainingPath, Action<object, string> callback, IPathNavigator pathNavigator)
            : base(objectToObserve, propertyName, remainingPath, callback, pathNavigator)
        {
            _actualHandler = CurrentTarget_PropertyChanged;
            _weakHandler = new WeakEventProxy<PropertyChangedEventArgs>(_actualHandler);
            _weakHandlerWrapper = _weakHandler.Handler;

            AcquireTarget(objectToObserve);
        }
Example #9
0
        /// <summary>
        /// Creates an appropriate property monitor for the remaining property path string on the target object.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="propertyPath">The property path.</param>
        /// <param name="callback">The callback.</param>
        /// <param name="pathNavigator">The path navigator.</param>
        /// <returns>
        /// An appropriate <see cref="IToken"/> for the property.
        /// </returns>
        public IToken ParseNext(object target, string propertyPath, Action<object, string> callback, IPathNavigator pathNavigator)
        {
            IToken result = null;
            if (target != null)
            {
                var propertyName = propertyPath;
                string remainingPath = null;
                var dotIndex = propertyPath.IndexOf('.');
                if (dotIndex >= 0)
                {
                    propertyName = propertyPath.Substring(0, dotIndex);
                    remainingPath = propertyPath.Substring(dotIndex + 1);
                }

                result = new ClrMemberToken(target, propertyName, remainingPath, callback, pathNavigator);
            }
            return result;
        }
 /// <summary>
 /// Creates an appropriate property monitor for the remaining property path string on the target object.
 /// </summary>
 /// <param name="target">The target.</param>
 /// <param name="propertyPath">The property path.</param>
 /// <param name="callback">The callback.</param>
 /// <param name="pathNavigator">The path navigator.</param>
 /// <returns>
 /// An appropriate <see cref="IToken"/> for the property.
 /// </returns>
 public IToken ParseNext(object target, string propertyPath, Action<object, string> callback, IPathNavigator pathNavigator)
 {
     IToken result = null;
     #if !SILVERLIGHT
     if (target is System.Windows.Forms.Control)
     {
         var propertyName = propertyPath;
         string remainingPath = null;
         var dotIndex = propertyPath.IndexOf('.');
         if (dotIndex >= 0)
         {
             propertyName = propertyPath.Substring(0, dotIndex);
             remainingPath = propertyPath.Substring(dotIndex + 1);
         }
         result = new WindowsFormsMemberToken(target, propertyName, remainingPath, callback, pathNavigator);
     }
     #endif
     return result;
 }
Example #11
0
        /// <summary>
        /// Creates an appropriate property monitor for the remaining property path string on the target object.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="propertyPath">The property path.</param>
        /// <param name="callback">The callback.</param>
        /// <param name="pathNavigator">The path navigator.</param>
        /// <returns>
        /// An appropriate <see cref="IToken"/> for the property.
        /// </returns>
        public IToken ParseNext(object target, string propertyPath, Action <object, string> callback, IPathNavigator pathNavigator)
        {
            IToken result = null;

            if (target != null)
            {
                var    propertyName  = propertyPath;
                string remainingPath = null;
                var    dotIndex      = propertyPath.IndexOf('.');
                if (dotIndex >= 0)
                {
                    propertyName  = propertyPath.Substring(0, dotIndex);
                    remainingPath = propertyPath.Substring(dotIndex + 1);
                }

                result = new ClrMemberToken(target, propertyName, remainingPath, callback, pathNavigator);
            }
            return(result);
        }
 /// <summary>
 /// Constructs a dependency for a single element.
 /// </summary>
 /// <param name="pathNavigator">The path navigator.</param>
 /// <returns></returns>
 public IDependency Attach(IPathNavigator pathNavigator)
 {
     return(new ExternalDependency(TargetObject, PropertyPath, pathNavigator));
 }
 public ExternalDependency(object targetObject, string propertyPath, IPathNavigator pathNavigator)
 {
     _rootMonitor = pathNavigator.TraverseNext(targetObject, propertyPath, Element_PropertyChanged);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ExplicitBindingConfiguration"/> class.
 /// </summary>
 public ExplicitBindingConfiguration()
 {
     _expressionAnalyzer = new ExpressionAnalyzer();
     _pathNavigator      = new PathNavigator(new WpfMemberTokenFactory(), new SilverlightMemberTokenFactory(), new WindowsFormsMemberTokenFactory(), new ClrMemberTokenFactory());
 }
 IDependency IDependencyDefinition.ConstructForElement <TElement>(TElement sourceElement, IPathNavigator pathNavigator)
 {
     return(ConstructForElement(sourceElement, pathNavigator));
 }
        public IToken ParseNext(object target, string propertyPath, Action <object, string> callback, IPathNavigator pathNavigator)
        {
            if (!(target is Control))
            {
                return(null);
            }
            var propertyName = propertyPath;
            var num          = propertyPath.IndexOf('.');

            if (num < 0)
            {
                return(new WindowsFormsMemberToken(target, propertyName, null, callback, pathNavigator));
            }

            propertyName = propertyPath.Substring(0, num);
            var remainingPath = propertyPath.Substring(num + 1);

            return(new WindowsFormsMemberToken(target, propertyName, remainingPath, callback, pathNavigator));
        }
 public IDependency ConstructForElement <TElement>(TElement sourceElement, IPathNavigator pathNavigator)
 {
     throw new NotImplementedException();
 }
 public SilverlightMemberToken(DependencyObject objectToObserve, DependencyProperty dependencyProperty, string propertyName, string remainingPath, Action <object, string> callback, IPathNavigator pathNavigator)
     : base(objectToObserve, propertyName, remainingPath, callback, pathNavigator)
 {
     _dependencyProperty = dependencyProperty;
     _actualHandler      = CurrentTarget_PropertyChanged;
     AcquireTarget(objectToObserve);
 }
 /// <summary>
 /// Constructs a dependency for a single element.
 /// </summary>
 /// <typeparam name="TElement">The type of the element.</typeparam>
 /// <param name="sourceElement">The source element.</param>
 /// <param name="pathNavigator">The path navigator.</param>
 /// <returns></returns>
 public IDependency ConstructForElement <TElement>(TElement sourceElement, IPathNavigator pathNavigator)
 {
     return(new ExternalDependency(TargetObject, PropertyPath, pathNavigator));
 }
Example #20
0
        /// <summary>
        /// Creates an appropriate property monitor for the remaining property path string on the target object.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="propertyPath">The property path.</param>
        /// <param name="callback">The callback.</param>
        /// <param name="pathNavigator">The path navigator.</param>
        /// <returns>
        /// An appropriate <see cref="IToken"/> for the property.
        /// </returns>
        public IToken ParseNext(object target, string propertyPath, Action <object, string> callback, IPathNavigator pathNavigator)
        {
            IToken result = null;

#if SILVERLIGHT
            if (target is DependencyObject)
            {
                string propertyName  = propertyPath;
                string remainingPath = null;
                int    dotIndex      = propertyPath.IndexOf('.');
                if (dotIndex >= 0)
                {
                    propertyName  = propertyPath.Substring(0, dotIndex);
                    remainingPath = propertyPath.Substring(dotIndex + 1);
                }

                DependencyObject dependencyObject = (DependencyObject)target;
                if (dependencyObject != null)
                {
                    FieldInfo field = dependencyObject.GetType().GetField(propertyName + "Property", BindingFlags.Public | BindingFlags.Static);
                    if (field != null)
                    {
                        DependencyProperty dependencyProperty = (DependencyProperty)field.GetValue(null);
                        if (dependencyProperty != null)
                        {
                            result = new SilverlightMemberToken(dependencyObject, dependencyProperty, propertyName, remainingPath, callback, pathNavigator);
                        }
                    }
                }
            }
#endif
            return(result);
        }
Example #21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WpfMemberToken"/> class.
        /// </summary>
        /// <param name="objectToObserve">The object to observe.</param>
        /// <param name="dependencyProperty">The dependency property.</param>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="remainingPath">The remaining path.</param>
        /// <param name="callback">The callback.</param>
        /// <param name="pathNavigator">The path navigator.</param>
        public WpfMemberToken(DependencyObject objectToObserve, DependencyProperty dependencyProperty, string propertyName, string remainingPath, Action <object, string> callback, IPathNavigator pathNavigator)
            : base(objectToObserve, propertyName, remainingPath, callback, pathNavigator)
        {
            _dependencyProperty = dependencyProperty;

            AcquireTarget(objectToObserve);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="WindowsFormsMemberToken"/> class.
        /// </summary>
        /// <param name="objectToObserve">The object to observe.</param>
        /// <param name="propertyName">The property path.</param>
        /// <param name="remainingPath">The remaining path.</param>
        /// <param name="callback">The callback.</param>
        /// <param name="pathNavigator">The path navigator.</param>
        public WindowsFormsMemberToken(object objectToObserve, string propertyName, string remainingPath, Action <object, string> callback, IPathNavigator pathNavigator)
            : base(objectToObserve, propertyName, remainingPath, callback, pathNavigator)
        {
            _actualHandler = CurrentTarget_PropertyChanged;

            AcquireTarget(objectToObserve);
        }
Example #23
0
 /// <summary>
 /// Constructs the dependency for a collection of elements.
 /// </summary>
 /// <typeparam name="TElement">The type of the element.</typeparam>
 /// <param name="sourceElements">The source elements.</param>
 /// <param name="pathNavigator">The path navigator.</param>
 /// <returns></returns>
 public IDependency ConstructForCollection <TElement>(IBindableCollection <TElement> sourceElements, IPathNavigator pathNavigator)
 {
     return(new ItemDependency <TElement>(PropertyPath, sourceElements, pathNavigator));
 }
        public IToken ParseNext(object target, string propertyPath, Action <object, string> callback, IPathNavigator pathNavigator)
        {
            IToken result = null;

            if (!(target is DependencyObject dependencyObject))
            {
                return(null);
            }
            var    text          = propertyPath;
            string remainingPath = null;
            var    num           = propertyPath.IndexOf('.');

            if (num >= 0)
            {
                text          = propertyPath.Substring(0, num);
                remainingPath = propertyPath.Substring(num + 1);
            }

            var field = dependencyObject.GetType().GetField(text + "Property", BindingFlags.Static | BindingFlags.Public);

            if (field == null)
            {
                return(null);
            }
            var dependencyProperty = (DependencyProperty)field.GetValue(null);

            if (dependencyProperty != null)
            {
                result = new WpfMemberToken(dependencyObject, dependencyProperty, text, remainingPath, callback, pathNavigator);
            }
            return(result);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultBindingConfiguration"/> class.
 /// </summary>
 public DefaultBindingConfiguration()
 {
     _expressionAnalyzer = new ExpressionAnalyzer(new ItemDependencyExtractor(), new ExternalDependencyExtractor(), new StaticDependencyExtractor());
     _pathNavigator      = new PathNavigator(new WpfMemberTokenFactory(), new SilverlightMemberTokenFactory(), new WindowsFormsMemberTokenFactory(), new ClrMemberTokenFactory());
 }
Example #26
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ClrMemberToken"/> class.
        /// </summary>
        /// <param name="objectToObserve">The object to observe.</param>
        /// <param name="propertyName">The property path.</param>
        /// <param name="remainingPath">The remaining path.</param>
        /// <param name="callback">The callback.</param>
        /// <param name="pathNavigator">The path navigator.</param>
        public ClrMemberToken(object objectToObserve, string propertyName, string remainingPath, Action <object, string> callback, IPathNavigator pathNavigator)
            : base(objectToObserve, propertyName, remainingPath, callback, pathNavigator)
        {
            _actualHandler      = CurrentTarget_PropertyChanged;
            _weakHandler        = new WeakEventProxy <PropertyChangedEventArgs>(_actualHandler);
            _weakHandlerWrapper = _weakHandler.Handler;

            AcquireTarget(objectToObserve);
        }
 /// <summary>
 /// Constructs the dependency for a collection of elements.
 /// </summary>
 /// <typeparam name="TElement">The type of the element.</typeparam>
 /// <param name="sourceElements">The source elements.</param>
 /// <param name="pathNavigator">The path navigator.</param>
 /// <returns></returns>
 public IDependency ConstructForCollection <TElement>(IBindableCollection <TElement> sourceElements, IPathNavigator pathNavigator)
 {
     return(new ExternalDependency(TargetObject, PropertyPath, pathNavigator));
 }
 public IToken ParseNext(object target, string propertyPath, Action <object, string> callback, IPathNavigator pathNavigator)
 {
     return(null);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ExternalDependency"/> class.
 /// </summary>
 /// <param name="targetObject">The target object.</param>
 /// <param name="propertyPath">The property path.</param>
 /// <param name="pathNavigator">The path navigator.</param>
 public ExternalDependency(object targetObject, string propertyPath, IPathNavigator pathNavigator)
 {
     _rootMonitor = pathNavigator.TraverseNext(targetObject, propertyPath, Element_PropertyChanged);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ExplicitBindingConfiguration"/> class.
 /// </summary>
 public ExplicitBindingConfiguration()
 {
     _expressionAnalyzer = new ExpressionAnalyzer();
     _pathNavigator = new PathNavigator(new WpfMemberTokenFactory(), new SilverlightMemberTokenFactory(), new WindowsFormsMemberTokenFactory(), new ClrMemberTokenFactory());
 }
 public IDependency ConstructForCollection <TElement>(IBindableCollection <TElement> sourceElements, IPathNavigator pathNavigator)
 {
     throw new NotImplementedException();
 }
        /// <summary>
        /// Creates an appropriate property monitor for the remaining property path string on the target object.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="propertyPath">The property path.</param>
        /// <param name="callback">The callback.</param>
        /// <param name="pathNavigator">The path navigator.</param>
        /// <returns>
        /// An appropriate <see cref="IToken"/> for the property.
        /// </returns>
        public IToken ParseNext(object target, string propertyPath, Action <object, string> callback, IPathNavigator pathNavigator)
        {
            IToken result = null;

#if !SILVERLIGHT
            if (target is System.Windows.Forms.Control)
            {
                var    propertyName  = propertyPath;
                string remainingPath = null;
                var    dotIndex      = propertyPath.IndexOf('.');
                if (dotIndex >= 0)
                {
                    propertyName  = propertyPath.Substring(0, dotIndex);
                    remainingPath = propertyPath.Substring(dotIndex + 1);
                }
                result = new WindowsFormsMemberToken(target, propertyName, remainingPath, callback, pathNavigator);
            }
#endif
            return(result);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultBindingConfiguration"/> class.
 /// </summary>
 public DefaultBindingConfiguration()
 {
     _expressionAnalyzer = new ExpressionAnalyzer(new ItemDependencyExtractor(), new ExternalDependencyExtractor(), new StaticDependencyExtractor());
     _pathNavigator = new PathNavigator(new WpfMemberTokenFactory(), new SilverlightMemberTokenFactory(), new WindowsFormsMemberTokenFactory(), new ClrMemberTokenFactory());
 }
Example #34
0
 /// <summary>
 /// Constructs a dependency for a single element.
 /// </summary>
 /// <param name="pathNavigator">The path navigator.</param>
 /// <returns></returns>
 public IDependency Attach(IPathNavigator pathNavigator)
 {
     throw new NotImplementedException();
 }