public FnNodeNameCall(XQueryStaticContext ctx, ExprSequence args) : base(ctx, "node-name", 1, 1, SequenceType.Create(XmlSchemaSimpleType.XsQName, Occurence.Optional), args) { }
public FnStringCallToCodepointsCall(XQueryStaticContext ctx, XPathItemExpression [] args) : base(ctx, "string-to-codepoints", 1, 1, SequenceType.Create(XmlSchemaSimpleType.XsString, Occurence.Optional), args) { }
public FnTraceCall(XQueryStaticContext ctx, XPathItemExpression [] args) : base(ctx, "trace", 2, 2, SequenceType.Create(XmlSchemaComplexType.AnyType, Occurence.ZeroOrMore), args) { }
public FnDocumentUriCall(XQueryStaticContext ctx, XPathItemExpression [] args) : base(ctx, "document-uri", 1, 1, SequenceType.Create(XmlSchemaSimpleType.XsAnyUri, Occurence.Optional), args) { }
public FnNilledCall(XQueryStaticContext ctx, XPathItemExpression [] args) : base(ctx, "nilled", 1, 1, SequenceType.Create(XmlSchemaSimpleType.XsBoolean, Occurence.One), args) { }
internal static XQueryCliFunction CreateFromMethodInfo(XmlQualifiedName name, MethodInfo [] methodList) { if (methodList == null || methodList.Length == 0) { throw new ArgumentException(String.Format("Argument methods is missing or zero-length array. Name is {0}", name)); } Type cliReturnType = null; ArrayList arguments = new ArrayList(); if (name == null || name == XmlQualifiedName.Empty) { name = new XmlQualifiedName(methodList [0].Name, methodList [0].DeclaringType.FullName); } int maxArgs = 0; int minArgs = -1; Hashtable methods = new Hashtable(); foreach (MethodInfo mi in methodList) { if (cliReturnType == null) { cliReturnType = mi.ReturnType; } else if (mi.ReturnType != cliReturnType) { throw new ArgumentException(String.Format("Every XQuery functions which share the same name must have the same return type. Method name is {0}.", mi.Name)); } ParameterInfo [] prms = mi.GetParameters(); int args = prms.Length; // Whether it takes "current context" or not. Type t = args > 0 ? prms [0].ParameterType : null; bool ctxSeq = mi.GetCustomAttributes(typeof(XQueryFunctionContextAttribute), false).Length > 0; bool hasContextArg = ctxSeq || t == typeof(XQueryContext); if (ctxSeq || hasContextArg) { args--; } if (methods [args] != null) { throw new ArgumentException(String.Format("XQuery does not allow functions that accepts such methods that have the same number of parameters in different types. Method name is {0}", mi.Name)); } methods.Add((int)args, mi); if (args < minArgs || minArgs < 0) { minArgs = args; } if (args > maxArgs) { maxArgs = args; } } MethodInfo m = (MethodInfo)methods [(int)maxArgs]; if (m == null) { throw new SystemException("Should not happen: maxArgs is " + maxArgs); } ParameterInfo [] pl = m.GetParameters(); for (int i = 0; i < pl.Length; i++) { Type t = pl [i].ParameterType; if (t != typeof(XQueryContext)) { arguments.Add( new XQueryFunctionArgument(new XmlQualifiedName(pl [i].Name), SequenceType.Create(pl [i].ParameterType))); } } return(new XQueryCliFunction(name, arguments.ToArray(typeof(XQueryFunctionArgument)) as XQueryFunctionArgument [], SequenceType.Create(cliReturnType), methods, minArgs, maxArgs)); }