| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- //
- // System.Xml.Query.XQueryCommand
- //
- // Author:
- // Tim Coleman ([email protected])
- // Atsushi Enomoto ([email protected])
- //
- // Copyright (C) Tim Coleman, 2003
- // Copyright (C) Novell Inc., 2004
- //
- //
- // Permission is hereby granted, free of charge, to any person obtaining
- // a copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to
- // permit persons to whom the Software is furnished to do so, subject to
- // the following conditions:
- //
- // The above copyright notice and this permission notice shall be
- // included in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- //
- #if NET_2_0
- using System.Data;
- using System.Data.SqlXml;
- using System.IO;
- using System.Reflection;
- using System.Security.Policy;
- using System.Xml;
- using System.Xml.XPath;
- namespace System.Xml.Query
- {
- public class XQueryCommand
- {
- // They are obtained via reflection
- static Type implType;
- static MethodInfo compileMethod;
- static MethodInfo executeMethod;
- static XQueryCommand ()
- {
- implType = typeof (XPathNavigator).Assembly.GetType ("Mono.Xml.XPath2.XQueryCommandImpl");
- compileMethod = implType.GetMethod ("Compile");
- executeMethod = implType.GetMethod ("Execute");
- if (compileMethod == null)
- throw new InvalidOperationException ("Should not happen: XQueryCommandImpl.Compile() was not found.");
- if (executeMethod == null)
- throw new InvalidOperationException ("Should not happen: XQueryCommandImpl.Execute() was not found.");
- }
- #region Constructor
- [MonoTODO]
- public XQueryCommand ()
- {
- impl = Activator.CreateInstance (implType);
- }
- #endregion // Constructor
- object impl;
- #region Event
- public event QueryEventHandler OnMessageEvent;
- #endregion
- #region Methods
- // Compile
- [MonoTODO ("Null Evidence allowed?")]
- public void Compile (string query)
- {
- Compile (query, null);
- }
- public void Compile (string query, Evidence evidence)
- {
- Compile (new StringReader (query), evidence);
- }
- [MonoTODO ("Null Evidence allowed?")]
- public void Compile (TextReader query)
- {
- Compile (query, null);
- }
- [MonoTODO]
- public void Compile (TextReader query, Evidence evidence)
- {
- compileMethod.Invoke (impl, new object [] {query, evidence, this});
- }
- // Execute
- [MonoTODO ("Null args allowed?")]
- public void Execute (
- IXPathNavigable contextDocument,
- XmlWriter results)
- {
- Execute (contextDocument, null, null, results);
- }
- [MonoTODO ("Output StartDocument?")]
- public void Execute (
- XmlResolver dataSources,
- TextWriter results)
- {
- XmlWriter w = XmlWriter.Create (results);
- Execute (dataSources, null, w);
- }
- [MonoTODO ("Null args allowed?")]
- public void Execute (
- XmlResolver dataSources,
- XmlWriter results)
- {
- Execute (new XPathDocument (), dataSources, null, results);
- }
- [MonoTODO ("Null args allowed?")]
- public void Execute (
- IXPathNavigable contextDocument,
- XmlArgumentList args,
- XmlWriter results)
- {
- Execute (contextDocument, null, args, results);
- }
- [MonoTODO ("Null args allowed?")]
- public void Execute (
- IXPathNavigable contextDocument,
- XmlResolver resolver,
- XmlWriter results)
- {
- Execute (contextDocument, resolver, null, results);
- }
- [MonoTODO("Indentation?;write StartDocument?;Null args allowed?")]
- public void Execute (
- string contextDocumentUri,
- XmlResolver dataSources,
- Stream results)
- {
- Execute (contextDocumentUri, dataSources, null, results);
- }
- [MonoTODO("Indentation?;write StartDocument?;Null args allowed?")]
- public void Execute (
- string contextDocumentUri,
- XmlResolver dataSources,
- TextWriter results)
- {
- Execute (contextDocumentUri, dataSources, null, results);
- }
- [MonoTODO]
- public void Execute (
- string contextDocumentUri,
- XmlResolver dataSources,
- XmlWriter results)
- {
- Execute (new XPathDocument (XmlReader.Create (contextDocumentUri)), dataSources, results);
- }
- [MonoTODO]
- public void Execute (
- XmlResolver dataSources,
- XmlArgumentList args,
- XmlWriter results)
- {
- Execute ((XPathNavigator) null, dataSources, args, results);
- }
- [MonoTODO]
- public void Execute (
- IXPathNavigable contextDocument,
- XmlResolver dataSources,
- XmlArgumentList args,
- XmlWriter results)
- {
- Execute (contextDocument != null ? contextDocument.CreateNavigator () : null, dataSources, args, results);
- }
- [MonoTODO]
- public void Execute (
- string contextDocumentUri,
- XmlResolver dataSources,
- XmlArgumentList args,
- Stream results)
- {
- Execute (new XPathDocument (XmlReader.Create (contextDocumentUri)), dataSources, args, XmlWriter.Create (results));
- }
- [MonoTODO]
- public void Execute (
- string contextDocumentUri,
- XmlResolver dataSources,
- XmlArgumentList args,
- TextWriter results)
- {
- Execute (new XPathDocument (XmlReader.Create (contextDocumentUri)), dataSources, args, XmlWriter.Create (results));
- }
- [MonoTODO]
- public void Execute (
- string contextDocumentUri,
- XmlResolver dataSources,
- XmlArgumentList args,
- XmlWriter results)
- {
- Execute (new XPathDocument (XmlReader.Create (contextDocumentUri)), dataSources, args, results);
- }
- private void Execute (XPathNavigator context, XmlResolver ds, XmlArgumentList args, XmlWriter output)
- {
- executeMethod.Invoke (impl, new object [] {context, ds, args, output});
- }
- #endregion // Methods
- }
- }
- #endif // NET_2_0
|