mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 10:22:55 +00:00
d6fbe2e60b
Make ScriptedMethods class static and convert the methods into extension methods (really just for the hell of it) Make some of the comments a little less verbose in terms of number of lines Some Resharper inspired simplifications Other code reformatting to make consistent with other parts of the project (switch case statements should have braces, ContinueWith blocks reformatted to match others) Untabify ScriptedMethodsTest.html Remove unused usings from ScriptedMethods Add a few comments about camelCaseJavascriptNames
40 lines
1.5 KiB
C#
40 lines
1.5 KiB
C#
// Copyright © 2010-2015 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;
|
|
|
|
namespace CefSharp.Example
|
|
{
|
|
/// <summary>
|
|
/// A class that is used to demonstrate how asynchronous javascript events can be returned to the .Net runtime environment.
|
|
/// </summary>
|
|
/// <seealso cref="ScriptedMethods"/>
|
|
/// <seealso cref="resources/ScriptedMethodsTest.html"/>
|
|
public class ScriptedMethodsBoundObject
|
|
{
|
|
/// <summary>
|
|
/// Raised when a Javascript event arrives.
|
|
/// </summary>
|
|
public event Action<string,object> EventArrived;
|
|
|
|
/// <summary>
|
|
/// This method will be exposed to the Javascript environment. It is
|
|
/// invoked in the Javascript environment when some event of interest
|
|
/// happens.
|
|
/// </summary>
|
|
/// <param name="eventName">The name of the event.</param>
|
|
/// <param name="eventData">Data provided by the invoker pertaining to the event.</param>
|
|
/// <remarks>
|
|
/// By default RaiseEvent will be translated to raiseEvent as a javascript function.
|
|
/// This is configurable when calling RegisterJsObject by setting camelCaseJavascriptNames;
|
|
/// </remarks>
|
|
public void RaiseEvent(string eventName, object eventData = null)
|
|
{
|
|
if (EventArrived != null)
|
|
{
|
|
EventArrived(eventName, eventData);
|
|
}
|
|
}
|
|
}
|
|
}
|