XdmModule.NativeModule Method (Type)XdmModule.NativeModule Method (Type)XdmModule::NativeModule Method (Type^)
- XmlPrime 3.0
- Other Versions ▼
Parameters
- type
Type: System.TypeSystem.TypeSystem::Type^
The type that contains methods to expose.
Return Value
Type: XmlPrime.XdmModuleXmlPrime.XdmModuleXmlPrime::XdmModule^
A new instance of XdmModuleXdmModuleXdmModule containing functions representing methods from type
Exceptions
Exception | Condition |
InvalidOperationExceptionInvalidOperationExceptionInvalidOperationException |
An InvalidOperationExceptionInvalidOperationExceptionInvalidOperationException is raised in the following conditions:
|
Remarks
For an example of the use of this function, see Modules.
Libraries of functions can be made available to an XQuery program, XPath expression or XSL transformation by adding them to the LibrariesLibrariesLibraries collection.
If type is annotated with the XdmModuleAttributeXdmModuleAttributeXdmModuleAttribute then the target
namespace can be specified by the attribute. If the attribute is not present, or the namespace is not
declared, then the namespace of the function library is a uri with the scheme clitype
. The
path of the URI is the full CLI name of the type.
Type | URI |
---|---|
MathMathMath | clitype:System.Math |
decimalDecimaldecimal | clitype:System.Decimal |
SpecialFolderSpecialFolderSpecialFolder |
clitype:System.Environment+SpecialFolder (note that this is an enumeration, and as such has no
static methods to import, but this still serves as an example of how to reference a nested type)
|
type must be a non-generic class, otherwise a NotSupportedExceptionNotSupportedExceptionNotSupportedException is thrown.
If type is annotated with the XdmModuleAttributeXdmModuleAttributeXdmModuleAttribute attribute, then only those methods marked with XdmFunctionAttributeXdmFunctionAttributeXdmFunctionAttribute will be included. If any of these methods fail to satisfy the conditions below then an InvalidOperationExceptionInvalidOperationExceptionInvalidOperationException is thrown.
If type is not annotated with the XdmModuleAttributeXdmModuleAttributeXdmModuleAttribute attribute, then only those methods satisfying the conditions below will be exported.
- The method is public.
- The method is not a generic method.
- The exported name of the method is a valid NCName value.
- The name of all the parameters are valid NCName values.
- The return type is supported.
- All the parameter types are supported.
- None of the parameters are ref or out parameters.
- None of the parameters are variable length argument lists.
- If the method is overloaded, then no overload has the same number of arguments.
If a method has the same exported name and number of arguments as a method in a base class that would be exported, then the base class methods with the same name and number of arguments are excluded.
Exported method can be marked with the XdmFunctionAttributeXdmFunctionAttributeXdmFunctionAttribute which allows the exported name of the method to be overridden. The parameters and return values of an exported method can be marked with the XdmTypeAttributeXdmTypeAttributeXdmTypeAttribute attribute which specifies the XDM type of the arguments and return types of the exported function.
More information about how native methods are bound to XQuery functions can be found on the Native modules page.