예제 #1
0
        /// <summary>
        /// Gets all the implemented interfaces of this <see cref="XObject"/>.
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public static IEnumerable <object> Interfaces(this XObject node, Type type)
        {
            Contract.Requires <ArgumentNullException>(node != null);
            Contract.Requires <ArgumentNullException>(type != null);

            return(Interfaces(node, type, node.Exports()));
        }
예제 #2
0
        /// <summary>
        /// Gets the existing <see cref="InterfaceEventListener"/> registered on the target.
        /// </summary>
        /// <param name="dispatcher"></param>
        /// <param name="eventType"></param>
        /// <param name="capture"></param>
        /// <param name="handler"></param>
        /// <param name="interfaceType"></param>
        /// <param name="methodInfo"></param>
        /// <returns></returns>
        public static InterfaceEventListener GetListener(EventTarget dispatcher, string eventType, bool capture, XObject handler, Type interfaceType, MethodInfo methodInfo)
        {
            Contract.Requires <ArgumentNullException>(dispatcher != null);
            Contract.Requires <ArgumentNullException>(!string.IsNullOrWhiteSpace(eventType));
            Contract.Requires <ArgumentNullException>(handler != null);
            Contract.Requires <ArgumentNullException>(interfaceType != null);
            Contract.Requires <ArgumentNullException>(methodInfo != null);
            Contract.Requires <ArgumentException>(IsValidMethodInfo(methodInfo));

            var host = handler.Exports().GetExportedValue <Func <Document> >()();

            if (host == null)
            {
                throw new InvalidOperationException();
            }

            // find existing listener
            var listener = Enumerable.Empty <EventListenerRegistration>()
                           .Concat(dispatcher.GetRegistrations())
                           .OfType <InterfaceEventListener>()
                           .Where(i => i.GetHandler(host) == handler)
                           .Where(i => i.InterfaceType == interfaceType)
                           .FirstOrDefault();

            return(listener);
        }
예제 #3
0
 /// <summary>
 /// Initializes a new instance.
 /// </summary>
 /// <param name="xml"></param>
 /// <param name="evaluationContext"></param>
 public EvaluationXsltContext(
     XObject xml,
     EvaluationContext evaluationContext)
     : this(xml.Exports().GetExportedValue <IXsltContextFunctionProvider>(), xml, evaluationContext)
 {
     Contract.Requires <ArgumentNullException>(xml != null);
     Contract.Requires <ArgumentNullException>(evaluationContext != null);
 }
예제 #4
0
 /// <summary>
 /// Initializes a new instance.
 /// </summary>
 /// <param name="xml"></param>
 /// <param name="evaluationContext"></param>
 public EvaluationXsltContext(
     XObject xml,
     EvaluationContext evaluationContext)
     : this(xml.Exports().GetExportedValue<IXsltContextFunctionProvider>(), xml, evaluationContext)
 {
     Contract.Requires<ArgumentNullException>(xml != null);
     Contract.Requires<ArgumentNullException>(evaluationContext != null);
 }
예제 #5
0
        /// <summary>
        /// Gets the existing <see cref="InterfaceEventListener"/> registered on the target.
        /// </summary>
        /// <param name="dispatcher"></param>
        /// <param name="eventType"></param>
        /// <param name="capture"></param>
        /// <param name="handler"></param>
        /// <param name="interfaceType"></param>
        /// <param name="methodInfo"></param>
        /// <returns></returns>
        public static InterfaceEventListener GetListener(EventTarget dispatcher, string eventType, bool capture, XObject handler, Type interfaceType, MethodInfo methodInfo)
        {
            Contract.Requires<ArgumentNullException>(dispatcher != null);
            Contract.Requires<ArgumentNullException>(!string.IsNullOrWhiteSpace(eventType));
            Contract.Requires<ArgumentNullException>(handler != null);
            Contract.Requires<ArgumentNullException>(interfaceType != null);
            Contract.Requires<ArgumentNullException>(methodInfo != null);
            Contract.Requires<ArgumentException>(IsValidMethodInfo(methodInfo));

            var host = handler.Exports().GetExportedValue<Func<Document>>()();
            if (host == null)
                throw new InvalidOperationException();

            // find existing listener
            var listener = Enumerable.Empty<EventListenerRegistration>()
                .Concat(dispatcher.GetRegistrations())
                .OfType<InterfaceEventListener>()
                .Where(i => i.GetHandler(host) == handler)
                .Where(i => i.InterfaceType == interfaceType)
                .FirstOrDefault();

            return listener;
        }