mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-05 19:54:53 +00:00
Add IJavascriptObjectRepository.UnRegister
Allows for an object to be removed from the repository, doesn't unbind the object from javascript though
This commit is contained in:
@@ -35,6 +35,13 @@ namespace CefSharp
|
||||
/// and other advanced options though this class.</param>
|
||||
void Register(string name, object objectToBind, bool isAsync = false, BindingOptions options = null);
|
||||
/// <summary>
|
||||
/// UnRegister a bound object from the repository. If you unregister an object that is currently
|
||||
/// bound in JavaScript then the method/property calls will fail.
|
||||
/// </summary>
|
||||
/// <param name="name">object name</param>
|
||||
/// <returns>returns true if the object was successfully unbound otherwise false.</returns>
|
||||
bool UnRegister(string name);
|
||||
/// <summary>
|
||||
/// Has bound objects
|
||||
/// </summary>
|
||||
bool HasBoundObjects { get; }
|
||||
|
||||
@@ -160,6 +160,21 @@ namespace CefSharp.Internals
|
||||
AnalyseObjectForBinding(jsObject, analyseMethods: true, analyseProperties: !isAsync, readPropertyValue: false, camelCaseJavascriptNames: camelCaseJavascriptNames);
|
||||
}
|
||||
|
||||
public bool UnRegister(string name)
|
||||
{
|
||||
foreach (var kvp in objects)
|
||||
{
|
||||
if(string.Equals(kvp.Value.Name, name, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
objects.Remove(kvp.Key);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
internal bool TryCallMethod(long objectId, string name, object[] parameters, out object result, out string exception)
|
||||
{
|
||||
exception = "";
|
||||
|
||||
Reference in New Issue
Block a user