-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Expand file tree
/
Copy pathIAsyncMethodInterceptor.cs
More file actions
38 lines (36 loc) · 1.88 KB
/
IAsyncMethodInterceptor.cs
File metadata and controls
38 lines (36 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright © 2020 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
using System;
using System.Threading.Tasks;
namespace CefSharp.ModelBinding
{
/// <summary>
/// Provides the capability intercept async/sync Net method calls made from javascript as part of the
/// JavascriptBinding (JSB) implementation. One example use case is logging method calls.
/// Extends <see cref="IMethodInterceptor"/> to add async support.
/// </summary>
public interface IAsyncMethodInterceptor : IMethodInterceptor
{
/// <summary>
/// Called before an async method is invoked. You are now responsible for evaluating
/// the function and returning the result. Only methods that return a <see cref="Task"/>
/// will call this method, other non asynchronous types will call
/// <see cref="IMethodInterceptor.Intercept(Func{object[], object}, object[], string)"/>.
/// (async void method will also call Intercept as they do not return a Task).
/// </summary>
/// <param name="method">A Func that represents the method to be called</param>
/// <param name="parameters">paramaters to be passed to <paramref name="method"/></param>
/// <param name="methodName">Name of the method to be called</param>
/// <returns>A Task representing the method result</returns>
/// <example>
/// Task<object> IAsyncMethodInterceptor.InterceptAsync(Func<object[], object> method, object[] parameters, string methodName)
/// {
/// object result = method(parameters);
/// Debug.WriteLine("Called " + methodName);
/// return result;
/// }
/// </example>
Task<object> InterceptAsync(Func<object[], object> method, object[] parameters, string methodName);
}
}