Пример #1
0
        /// <summary>
        /// Returns a new <see cref="Binding"/> instance for the specified element and expression.
        /// </summary>
        /// <param name="attribute"></param>
        /// <returns></returns>
        public static Binding ForAttribute(XAttribute attribute)
        {
            // ignore empty attributes
            if (attribute == null ||
                attribute.Value == null ||
                attribute.Value == "")
            {
                return(null);
            }

            var resolver = attribute.InterfaceOrDefault <EvaluationContextResolver>();

            if (resolver == null)
            {
                throw new DOMTargetEventException(attribute.Parent, Events.BindingException,
                                                  "Missing EvaluationContextResolver interface.");
            }

            var context = resolver.Context;

            if (context == null)
            {
                throw new DOMTargetEventException(attribute.Parent, Events.BindingException,
                                                  "Missing EvaluationContextResolver Context.");
            }

            return(new Binding(attribute.Parent, context, attribute.Value));
        }