/// <summary xml:lang="en"> /// Registering other custom method to the OData query parser /// </summary> /// <summary xml:lang="cs"> /// Registrace dodatečné vlastní metody do OData query parseru /// </summary> public static void RegisterCustomFunction(MethodInfo methodInfo, string functionName = null) { var returnType = TypeToReference(methodInfo.ReturnType); var args = methodInfo.GetParameters() .Select(x => TypeToReference(x.ParameterType)) .ToArray(); var signature = new FunctionSignatureWithReturnType(returnType, args); ODataUriFunctions.AddCustomUriFunction(functionName ?? methodInfo.Name.ToLower(), signature, methodInfo); }
public static void RegisterFunctions(IEdmTypeReference enumRef) { if (!registred) { lock (locker) { if (!registred) { RegisterFunction(typeof(BoundFunctions), nameof(BoundFunctions.GetBestOrders)); RegisterFunction(typeof(SelectExpandTestCustomerWithCustom), nameof(SelectExpandTestCustomerWithCustom.GetInstanceBestOrders)); RegisterFunction(typeof(SelectExpandTestCustomerWithCustom), nameof(SelectExpandTestCustomerWithCustom.GetInt)); RegisterFunction(typeof(SelectExpandTestCustomerWithCustom), nameof(SelectExpandTestCustomerWithCustom.ConvertEnum)); var s = new FunctionSignatureWithReturnType(EdmLibHelpers.GetEdmPrimitiveTypeReferenceOrNull(typeof(double?)), enumRef); ODataUriFunctions.AddCustomUriFunction("convert_enum", s, typeof(BoundFunctions).GetMethods().Where(m => m.Name == nameof(BoundFunctions.ConvertEnum)).First()); registred = true; } } } }