예제 #1
0
        public object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext)
        {
            OPathXsltContext opathXsltContext = (OPathXsltContext)xsltContext;

            IDictionary <string, OPathCustomFunction> customFunctions =
                opathXsltContext.CustomFunctions;

            string customFunctionKey = GetCustomFunctionKey(this.Prefix, this.Name);

            OPathCustomFunction customFunction;

            if (customFunctions.TryGetValue(customFunctionKey, out customFunction))
            {
                OPathCustomTypeConverter customTypeConverter = opathXsltContext.CustomTypeConverter;

                object result = customFunction(args);

                object convertedResult = customTypeConverter(result);

                return(convertedResult);
            }
            else
            {
                throw new OPathException("Could not resolve the custom function " + customFunctionKey);
            }
        }
예제 #2
0
        public object Evaluate(XsltContext xsltContext)
        {
            OPathXsltContext opathXsltContext = (OPathXsltContext)xsltContext;

            IDictionary <string, object> variables           = opathXsltContext.Variables;
            OPathCustomTypeConverter     customTypeConverter = opathXsltContext.CustomTypeConverter;

            object value;

            if (!variables.TryGetValue(this.Name, out value))
            {
                throw new OPathException(
                          string.Format("Variable {0} was not found in the OPathXsltContext.", this.Name));
            }

            object convertedValue = customTypeConverter(value);

            return(convertedValue);
        }