-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync Javascript Binding - Add support for property interception (#3935)
* Core - added support for property interceptor * Incorporated the review comments * Incorporated the review comments 2 * Review comments exclude trygetproperty and trysetproperty for .netcore app * Added the unit test cases for trygetproperty and trysetproperty * Fixed .net core app build failure * Added the separate test case for property interceptor Co-authored-by: sghanti <santosh_ghanti@intuit.com>
- Loading branch information
Showing
10 changed files
with
164 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
CefSharp.Example/ModelBinding/PropertyInterceptorLogger.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright © 2022 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.Diagnostics; | ||
using CefSharp.ModelBinding; | ||
|
||
namespace CefSharp.Example.ModelBinding | ||
{ | ||
public class PropertyInterceptorLogger : IPropertyInterceptor | ||
{ | ||
object IPropertyInterceptor.InterceptGet(Func<object> propertyGetter, string propertyName) | ||
{ | ||
object result = propertyGetter(); | ||
Debug.WriteLine("InterceptGet " + propertyName); | ||
return result; | ||
} | ||
|
||
void IPropertyInterceptor.InterceptSet(Action<object> propertySetter, object parameter, string propertName) | ||
{ | ||
Debug.WriteLine("InterceptSet " + propertName); | ||
propertySetter(parameter); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace CefSharp.ModelBinding | ||
{ | ||
/// <summary> | ||
/// Provides the capability intercepting get/set property calls made from javascript as part of the | ||
/// JavascriptBinding (JSB) implementation. | ||
/// </summary> | ||
public interface IPropertyInterceptor | ||
{ | ||
/// <summary> | ||
/// Called before the get property is invokved. You are now responsible for evaluating | ||
/// the property and returning the result. | ||
/// </summary> | ||
/// <param name="propertyGetter">A Func that represents the property to be called</param> | ||
/// <param name="propertName">Name of the property to be called</param> | ||
/// <returns>The property result</returns> | ||
/// <example> | ||
/// <code> | ||
/// <![CDATA[ | ||
/// public object IPropertyInterceptor.InterceptGet(Func<object> propertyGetter, string propertyName) | ||
/// { | ||
/// object result = propertyGetter(); | ||
/// Debug.WriteLine("InterceptGet " + propertyName); | ||
/// return result; | ||
/// } | ||
/// ]]> | ||
/// </code> | ||
/// </example> | ||
object InterceptGet(Func<object> propertyGetter, string propertName); | ||
|
||
/// <summary> | ||
/// Called before the set property is invokved. You are now responsible for evaluating | ||
/// the property. | ||
/// </summary> | ||
/// <param name="propertySetter">A Func that represents the property to be called</param> | ||
/// <param name="parameter">paramater to be set to property</param> | ||
/// <param name="propertName">Name of the property to be called</param> | ||
/// <example> | ||
/// <code> | ||
/// <![CDATA[ | ||
/// public object IPropertyInterceptor.InterceptSet(Action<object> propertySetter, object parameter, string propertName) | ||
/// { | ||
/// Debug.WriteLine("InterceptSet " + propertName); | ||
/// propertySetter(parameter); | ||
/// } | ||
/// ]]> | ||
/// </code> | ||
/// </example> | ||
void InterceptSet(Action<Object> propertySetter, object parameter, string propertName); | ||
} | ||
} |