/// <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())); }
/// <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); }
/// <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); }
/// <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); }
/// <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; }