-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Sync Javascript Binding - Add support for property interception #3935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4d1bb4a
Core - added support for property interceptor
6398b35
Incorporated the review comments
santoshmgh 9f471f7
Merge branch 'master' into master
santoshmgh 4e39c05
Incorporated the review comments 2
santoshmgh b50946d
Merge branch 'master' of https://github.com/santoshmgh/CefSharp
santoshmgh dc9eece
Merge branch 'master' into master
santoshmgh b577cfc
Review comments exclude trygetproperty and trysetproperty for .netcor…
santoshmgh 3b20c2e
Merge branch 'master' of https://github.com/santoshmgh/CefSharp
santoshmgh 33885b0
Merge branch 'master' into master
santoshmgh 0ef9cc2
Added the unit test cases for trygetproperty and trysetproperty
santoshmgh d9f6fa1
Merge branch 'master' of https://github.com/santoshmgh/CefSharp
santoshmgh 906c1e6
Fixed .net core app build failure
santoshmgh f266705
Added the separate test case for property interceptor
santoshmgh 1699fe5
Merge branch 'master' into master
santoshmgh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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; | ||
amaitland marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.