static XQueryInvoker With(Uri queryUri, IXQueryProcessor processor, Assembly callingAssembly) { if (queryUri == null) { throw new ArgumentNullException("queryUri"); } var resolver = new XmlDynamicResolver(callingAssembly); if (!queryUri.IsAbsoluteUri) { queryUri = resolver.ResolveUri(null, queryUri.OriginalString); } if (processor == null) { processor = Processors.XQuery.DefaultProcessor; } ConcurrentDictionary <Uri, XQueryExecutable> cache = uriCache.GetOrAdd(processor, p => new ConcurrentDictionary <Uri, XQueryExecutable>()); XQueryExecutable executable = cache.GetOrAdd(queryUri, u => { using (var stylesheetSource = (Stream)resolver.GetEntity(queryUri, null, typeof(Stream))) { return(processor.Compile(stylesheetSource, new XQueryCompileOptions { BaseUri = queryUri, XmlResolver = resolver })); } }); return(new XQueryInvoker(executable, callingAssembly)); }
internal static XQueryInvoker WithQuery(string query, IXQueryProcessor processor, Assembly callingAssembly, out int hashCode) { if (query == null) { throw new ArgumentNullException("query"); } if (processor == null) { processor = Processors.XQuery.DefaultProcessor; } hashCode = query.GetHashCode(); ConcurrentDictionary <int, XQueryExecutable> cache = inlineCache.GetOrAdd(processor, p => new ConcurrentDictionary <int, XQueryExecutable>()); XQueryExecutable exec = cache.GetOrAdd(hashCode, i => { var resolver = new XmlDynamicResolver(callingAssembly); return(processor.Compile(new StringReader(query), new XQueryCompileOptions { XmlResolver = resolver })); }); return(new XQueryInvoker(exec, callingAssembly)); }
public IEnumerable <XPathItem> Eval(XPathItem module, XPathItem input, IEnumerable <XPathNavigator> parameters) { XQueryInvoker invoker; IXQueryProcessor currentOrDefaultProc = this.CurrentXQueryProcessor ?? Processors.XQuery.DefaultProcessor; if (module.IsNode) { XPathNavigator node = ((XPathNavigator)module).Clone(); if (node.NodeType == XPathNodeType.Root) { node.MoveToChild(XPathNodeType.Element); } if (node.NodeType == XPathNodeType.Element && node.NamespaceURI == Namespace) { XmlSerializer serializer = XPathItemFactory.GetSerializer(typeof(CompiledQueryReference)); var reference = (CompiledQueryReference)serializer.Deserialize(node.ReadSubtree()); IXQueryProcessor specifiedProcessor = (reference.Processor != null) ? Processors.XQuery[reference.Processor] : null; invoker = (reference.HashCode > 0) ? XQueryInvoker.WithQuery(reference.HashCode, specifiedProcessor ?? currentOrDefaultProc) : XQueryInvoker.With(reference.Uri, specifiedProcessor); } else { invoker = XQueryInvoker.WithQuery(module.Value, currentOrDefaultProc); } } else { object value = module.TypedValue; if (value.GetType().IsPrimitive) { int hashCode = Convert.ToInt32(value, CultureInfo.InvariantCulture); invoker = XQueryInvoker.WithQuery(hashCode, currentOrDefaultProc); } else { Uri moduleUri = ResolveUri(module); invoker = XQueryInvoker.WithQuery(module.Value, currentOrDefaultProc); } } XQueryRuntimeOptions options = GetRuntimeOptions(input, parameters); return(invoker.Query(options).Result()); }
internal static XQueryInvoker WithQuery(int stylesheetHashCode, IXQueryProcessor processor) { if (processor == null) { processor = Processors.XQuery.DefaultProcessor; } return(new XQueryInvoker(inlineCache[processor][stylesheetHashCode], null)); }
public XPathItem CompileFrom(string moduleUri, string processor) { IXQueryProcessor proc = (processor != null) ? Processors.XQuery[processor] : Processors.XQuery.DefaultProcessor; Uri uri = this.Resolver.ResolveUri(null, moduleUri); XQueryInvoker.With(uri, proc); var reference = new CompiledQueryReference { Uri = uri.AbsoluteUri, Processor = processor }; return(this.ItemFactory.CreateDocument(reference) .CreateNavigator()); }
public override void GenerateCode(AssemblyBuilder assemblyBuilder) { base.GenerateCode(assemblyBuilder); // test compilation XQueryPageParser xqueryParser = (XQueryPageParser)Parser; IXQueryProcessor proc = Processors.XQuery[xqueryParser.ProcessorName]; using (Stream source = this.OpenStream()) { try { proc.Compile(source, new XQueryCompileOptions { BaseUri = this.PhysicalPath }); } catch (ProcessorException ex) { throw CreateCompileException(ex); } } }
public XPathItem CompileQuery(string query, string processor) { IXQueryProcessor proc = (processor != null) ? Processors.XQuery[processor] : this.CurrentXQueryProcessor ?? Processors.XQuery.DefaultProcessor; int hashCode; XQueryInvoker.WithQuery(query, proc, null, out hashCode); if (processor == null) { return(this.ItemFactory.CreateAtomicValue(hashCode, XmlTypeCode.Integer)); } var reference = new CompiledQueryReference { HashCode = hashCode, Processor = processor }; return(this.ItemFactory.CreateDocument(reference) .CreateNavigator()); }
internal static XQueryInvoker WithQuery(string query, IXQueryProcessor processor, Assembly callingAssembly, out int hashCode) { if (query == null) throw new ArgumentNullException("query"); if (processor == null) { processor = Processors.XQuery.DefaultProcessor; } hashCode = query.GetHashCode(); ConcurrentDictionary<int, XQueryExecutable> cache = inlineCache.GetOrAdd(processor, p => new ConcurrentDictionary<int, XQueryExecutable>()); XQueryExecutable exec = cache.GetOrAdd(hashCode, i => { var resolver = new XmlDynamicResolver(callingAssembly); return processor.Compile(new StringReader(query), new XQueryCompileOptions { XmlResolver = resolver }); }); return new XQueryInvoker(exec, callingAssembly); }
static XQueryInvoker With(string queryUri, IXQueryProcessor processor, Assembly callingAssembly) { return With(new Uri(queryUri, UriKind.RelativeOrAbsolute), processor, callingAssembly); }
static XQueryInvoker With(Uri queryUri, IXQueryProcessor processor, Assembly callingAssembly) { if (queryUri == null) throw new ArgumentNullException("queryUri"); var resolver = new XmlDynamicResolver(callingAssembly); if (!queryUri.IsAbsoluteUri) { queryUri = resolver.ResolveUri(null, queryUri.OriginalString); } if (processor == null) { processor = Processors.XQuery.DefaultProcessor; } ConcurrentDictionary<Uri, XQueryExecutable> cache = uriCache.GetOrAdd(processor, p => new ConcurrentDictionary<Uri, XQueryExecutable>()); XQueryExecutable executable = cache.GetOrAdd(queryUri, u => { using (var stylesheetSource = (Stream)resolver.GetEntity(queryUri, null, typeof(Stream))) { return processor.Compile(stylesheetSource, new XQueryCompileOptions { BaseUri = queryUri, XmlResolver = resolver }); } }); return new XQueryInvoker(executable, callingAssembly); }
static XQueryInvoker WithQuery(string query, IXQueryProcessor processor, Assembly callingAssembly) { int hashCode; return WithQuery(query, processor, callingAssembly, out hashCode); }
static XQueryInvoker With(string queryUri, IXQueryProcessor processor, Assembly callingAssembly) { return(With(new Uri(queryUri, UriKind.RelativeOrAbsolute), processor, callingAssembly)); }
public static XQueryInvoker With(Uri queryUri, IXQueryProcessor processor) { return(With(queryUri, processor, Assembly.GetCallingAssembly())); }
public static XQueryInvoker With(Uri queryUri, IXQueryProcessor processor) { return With(queryUri, processor, Assembly.GetCallingAssembly()); }
internal static XQueryInvoker WithQuery(int stylesheetHashCode, IXQueryProcessor processor) { if (processor == null) { processor = Processors.XQuery.DefaultProcessor; } return new XQueryInvoker(inlineCache[processor][stylesheetHashCode], null); }
static XQueryInvoker WithQuery(string query, IXQueryProcessor processor, Assembly callingAssembly) { int hashCode; return(WithQuery(query, processor, callingAssembly, out hashCode)); }
public static XQueryInvoker WithQuery(string query, IXQueryProcessor processor) { return(WithQuery(query, processor, Assembly.GetCallingAssembly())); }
public static XQueryInvoker WithQuery(string query, IXQueryProcessor processor) { return WithQuery(query, processor, Assembly.GetCallingAssembly()); }