using System.Data;\r
using System.Data.SqlXml;\r
using System.IO;\r
+using System.Reflection;\r
+using System.Security.Policy;\r
+using System.Xml;\r
+using System.Xml.XPath;\r
\r
namespace System.Xml.Query \r
{\r
public class XQueryCommand\r
{\r
- #region Constructors\r
+ // They are obtained via reflection\r
+ static Type implType;\r
+ static MethodInfo compileMethod;\r
+ static MethodInfo executeMethod;\r
+\r
+ static XQueryCommand ()\r
+ {\r
+ implType = typeof (XPathNavigator).Assembly.GetType ("Mono.Xml.XPath2.XQueryCommandImpl");\r
+ compileMethod = implType.GetMethod ("Compile");\r
+ executeMethod = implType.GetMethod ("Execute");\r
+ if (compileMethod == null)\r
+ throw new InvalidOperationException ("Should not happen: XQueryCommandImpl.Compile() was not found.");\r
+ if (executeMethod == null)\r
+ throw new InvalidOperationException ("Should not happen: XQueryCommandImpl.Execute() was not found.");\r
+ }\r
+\r
+ #region Constructor\r
\r
[MonoTODO]\r
public XQueryCommand ()\r
{\r
+ impl = Activator.CreateInstance (implType);\r
}\r
\r
- #endregion // Constructors\r
+ #endregion // Constructor\r
\r
- #region Properties\r
+ object impl;\r
\r
- [MonoTODO]\r
- public SqlQueryOptions SqlQueryOptions {\r
- get { throw new NotImplementedException (); }\r
- set { throw new NotImplementedException (); }\r
- }\r
+ #region Event\r
\r
- [MonoTODO]\r
- public XmlMappingDictionary XmlMappingDictionary {\r
- get { throw new NotImplementedException (); }\r
- set { throw new NotImplementedException (); }\r
- }\r
+ public event QueryEventHandler OnMessageEvent;\r
\r
- #endregion // Properties\r
+ #endregion\r
\r
#region Methods\r
\r
Compile (query, null);\r
}\r
\r
- [MonoTODO]\r
public void Compile (string query, Evidence evidence)\r
{\r
- throw new NotImplementedException ();\r
+ Compile (new StringReader (query), evidence);\r
}\r
\r
[MonoTODO ("Null Evidence allowed?")]\r
[MonoTODO]\r
public void Compile (TextReader query, Evidence evidence)\r
{\r
- throw new NotImplementedException ();\r
- }\r
-\r
- // CompileView\r
-\r
- [MonoTODO]\r
- public void CompileView (string query, string mappingLocation)\r
- {\r
- throw new NotImplementedException ();\r
- }\r
-\r
- [MonoTODO]\r
- public void CompileView (TextReader query, string mappingLocation)\r
- {\r
- throw new NotImplementedException ();\r
+ compileMethod.Invoke (impl, new object [] {query, evidence, this});\r
}\r
\r
// Execute\r
XmlResolver dataSources, \r
TextWriter results)\r
{\r
- XmlTextWriter w = new XmlTextWriter (results);\r
+ XmlWriter w = XmlWriter.Create (results);\r
Execute (dataSources, null, w);\r
}\r
\r
XmlResolver dataSources, \r
XmlWriter results)\r
{\r
- Execute ((IXPathNavigable) null, dataSources, null, results);\r
+ Execute (new XPathDocument (), dataSources, null, results);\r
}\r
\r
[MonoTODO ("Null args allowed?")]\r
XmlResolver dataSources, \r
XmlWriter results)\r
{\r
- throw new NotImplementedException ();\r
+ Execute (new XPathDocument (XmlReader.Create (contextDocumentUri)), dataSources, results);\r
}\r
\r
[MonoTODO]\r
XmlArgumentList args,\r
XmlWriter results)\r
{\r
- throw new NotImplementedException ();\r
+ Execute ((XPathNavigator) null, dataSources, args, results);\r
}\r
\r
[MonoTODO]\r
XmlArgumentList args,\r
XmlWriter results)\r
{\r
- throw new NotImplementedException ();\r
+ Execute (contextDocument != null ? contextDocument.CreateNavigator () : null, dataSources, args, results);\r
}\r
\r
[MonoTODO]\r
XmlArgumentList args,\r
Stream results)\r
{\r
- throw new NotImplementedException ();\r
+ Execute (new XPathDocument (XmlReader.Create (contextDocumentUri)), dataSources, args, XmlWriter.Create (results));\r
}\r
\r
[MonoTODO]\r
XmlArgumentList args,\r
TextWriter results)\r
{\r
- throw new NotImplementedException ();\r
+ Execute (new XPathDocument (XmlReader.Create (contextDocumentUri)), dataSources, args, XmlWriter.Create (results));\r
}\r
\r
[MonoTODO]\r
XmlArgumentList args,\r
XmlWriter results)\r
{\r
- throw new NotImplementedException ();\r
+ Execute (new XPathDocument (XmlReader.Create (contextDocumentUri)), dataSources, args, results);\r
}\r
\r
- // ExecuteView\r
-\r
- [MonoTODO]\r
- public void ExecuteView (IDbConnection connection, TextWriter results)\r
+ private void Execute (XPathNavigator context, XmlResolver ds, XmlArgumentList args, XmlWriter output)\r
{\r
- throw new NotImplementedException ();\r
+ executeMethod.Invoke (impl, new object [] {context, ds, args, output});\r
}\r
\r
#endregion // Methods\r