Implementing XmlExternalFunction
XmlExternalFunction implementations only require you to implement the Execute(XmlManager, XmlArguments) method with your function code.
The Execute
method has the following parameters:
XmlTransaction - This is the transaction in use, if any, at the time the external function was called.
Note
This argument only applies to Figaro Transactional Data Store (TDS) Edition.
XmlManager - The manager instance in use at the time when the function was called.
- @Figaro.XmlArguments* - An array of XmlResults objects which hold the current argument values needed by this function.
For example, suppose you wanted to write an external function that takes two numbers and returns the first number to the power of the second number. It would look like this:
using System;
using System.Diagnostics;
using Figaro.Xml;
class PowFunction: XmlExternalFunction
{
#if TDS
public override XmlResults Execute(XmlTransaction txn, XmlManager mgr, XmlArguments args)
#else
public override XmlResults Execute(XmlManager mgr, XmlArguments args)
#endif
{
var ret = mgr.CreateXmlResults();
var arg0 = args.GetArguments(0);
var arg1 = args.GetArguments(1);
Trace.WriteLine("executing PowFuction");
ret.Add(new XmlValue(Math.Pow(arg0.NextValue().AsNumber,arg1.NextValue().AsNumber)));
return ret;
}
}