Beispiel #1
0
        /// <summary>
        /// Finds all signatures for the given function name.
        /// Search in both BuiltIn uri functions and Custom uri functions.
        /// Combine and return the signatures overloads of the results.
        /// </summary>
        /// <param name="functionName">The function to get the signatures for.</param>
        /// <returns>The signatures which match the supplied function name.</returns>
        internal static FunctionSignatureWithReturnType[] GetUriFunctionSignatures(string functionName)
        {
            FunctionSignatureWithReturnType[] customUriFunctionsSignatures  = null;
            FunctionSignatureWithReturnType[] builtInUriFunctionsSignatures = null;

            // Try to find the function in the user custom functions and in our built-in functions
            bool customFound  = CustomUriFunctions.TryGetCustomFunction(functionName, out customUriFunctionsSignatures);
            bool builtInFound = BuiltInUriFunctions.TryGetBuiltInFunction(functionName, out builtInUriFunctionsSignatures);

            if (!customFound && !builtInFound)
            {
                // Not found in both built-in and custom.
                throw new ODataException(ODataErrorStrings.MetadataBinder_UnknownFunction(functionName));
            }

            if (!customFound)
            {
                Debug.Assert(builtInUriFunctionsSignatures != null, "No Built-in functions found");
                return(builtInUriFunctionsSignatures);
            }

            if (!builtInFound)
            {
                Debug.Assert(customUriFunctionsSignatures != null, "No Custom functions found");
                return(customUriFunctionsSignatures);
            }

            return(builtInUriFunctionsSignatures.Concat(customUriFunctionsSignatures).ToArray());
        }
Beispiel #2
0
 public void UnqualifiedFunctionInQueryTest()
 {
     this.TestUnqualified(
         "People?$orderby=TestNS.FindPencil(pid=2)/Id",
         "People?$orderby=FindPencil(pid=2)/Id",
         parser => parser.ParseOrderBy(),
         clause => clause.Expression.ShouldBeSingleValuePropertyAccessQueryNode(PencilId).And.Source.ShouldBeSingleEntityFunctionCallNode("TestNS.FindPencil"),
         Strings.MetadataBinder_UnknownFunction("FindPencil"));
 }
        /// <summary>
        /// Finds all signatures for the given function name.
        /// </summary>
        /// <param name="functionName">The function to get the signatures for.</param>
        /// <returns>The signatures which match the supplied function name.</returns>
        internal static FunctionSignatureWithReturnType[] GetBuiltInFunctionSignatures(string functionName)
        {
            // Try to find the function in our built-in functions
            FunctionSignatureWithReturnType[] signatures;
            if (!BuiltInFunctions.TryGetBuiltInFunction(functionName, out signatures))
            {
                throw new ODataException(ODataErrorStrings.MetadataBinder_UnknownFunction(functionName));
            }

            return(signatures);
        }