Exemple #1
0
        private FunctionSignatureWithReturnType[] GetCustomFunctionSignaturesOrNull(string customFunctionName)
        {
            FunctionSignatureWithReturnType[] resultFunctionSignaturesWithReturnType = null;
            CustomUriFunctions.TryGetCustomFunction(customFunctionName, out resultFunctionSignaturesWithReturnType);

            return(resultFunctionSignaturesWithReturnType as FunctionSignatureWithReturnType[]);
        }
Exemple #2
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());
        }
        private FunctionSignatureWithReturnType[] GetCustomFunctionSignaturesOrNull(string customFunctionName)
        {
            IList <KeyValuePair <string, FunctionSignatureWithReturnType> > resultFunctionSignaturesWithReturnType = null;

            CustomUriFunctions.TryGetCustomFunction(customFunctionName, out resultFunctionSignaturesWithReturnType);

            return(resultFunctionSignaturesWithReturnType?.Select(_ => _.Value).ToArray());
        }