Files
cefsharp/CefSharp/JavascriptBinding/IJavascriptNameConverter.cs
T
Alex Maitland b5a83f526e Enhancement - Pluggable Javascript Naming (#3141)
* Core - Move NameConverter to IJavascriptObjectRepository

- Move NameConverter property from BindingOptions to IJavascriptObjectRepository
- Remove BindingOptions.CamelCaseJavascriptNames

**Breaking Change**

Follow up to https://github.com/cefsharp/CefSharp/commit/898ca38e7a7261b3a42c33b2abf5eac6c022ddde

* Core - Javascript Binding Pluggable Naming Improvements

- Added some basic unit tests (more required)
- DefaultBinder now accepts a IJavascriptNameConverter passed into the constructor
  to allow for conversion of names

* Core - Replace WeakReference with WeakReference<T>
2020-07-27 20:13:16 +10:00

36 lines
1.5 KiB
C#

// 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.Reflection;
namespace CefSharp.JavascriptBinding
{
/// <summary>
/// Implement this interface to have control of how the names
/// are converted when binding/executing javascript.
/// </summary>
public interface IJavascriptNameConverter
{
/// <summary>
/// Get the javascript name for the property/field/method.
/// Typically this would be based on <see cref="MemberInfo.Name"/>
/// </summary>
/// <param name="memberInfo">property/field/method</param>
/// <returns>javascript name</returns>
string ConvertToJavascript(MemberInfo memberInfo);
/// <summary>
/// This method exists for backwards compatability reasons, historically
/// only the bound methods/fields/properties were converted. Objects returned
/// from a method call were not translated. To preserve this functionality
/// for upgrading users we split this into two methods. Typically thie method
/// would return the same result as <see cref="ConvertToJavascript(string)"/>
/// Issue #2442
/// </summary>
/// <param name="memberInfo">property/field/method</param>
/// <returns>javascript name</returns>
string ConvertReturnedObjectPropertyAndFieldToNameJavascript(MemberInfo memberInfo);
}
}