Ejemplo n.º 1
0
        /// <summary>
        /// Evaluates the path or xpath specified in a <see cref="BindingExtension"/> to a property of the assigned DataContext of the supplied <see cref="BaseMap"/>.
        /// </summary>
        /// <param name="src">The supplied source object, usually the DataContext of a <see cref="BaseMap"/> derived element.</param>
        /// <param name="bindingExtension">The binding on which the source object</param>
        /// <returns>The evaluated value</returns>
        private static object Evaluate(object src, BindingExtension bindingExtension)
        {
            if (src == null || bindingExtension == null)
            {
                return(null);
            }

            try
            {
                if (!string.IsNullOrEmpty(bindingExtension.XPath))
                {
                    return(GetPropValueFromXPath(src, bindingExtension.XPath));
                }
                else
                {
                    return(GetPropValue(src, bindingExtension.Path));
                }
            }
            catch
            {
                // Really, should raise some sort of error as the property path is invalid on a null - but this is what WPF bindings do...
                System.Diagnostics.Debug.Print("Map.EvaluatePath failed: {0}, Source={1}", bindingExtension, src);
                return(null);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BindingContainer" /> class.<br/>
        /// No public ctor. Can only create from a binding using Create.
        /// </summary>
        /// <param name="binding">The <see cref="BindingExtension"/> which this container will used to evaluate and store values.</param>
        private BindingContainer(BindingExtension binding)
        {
            if (binding == null)
            {
                throw new ArgumentNullException("binding");
            }

            this.binding         = binding;
            this.evaluatedResult = new UnevaluatedBindingResult();
        }