Hybrid Bridge
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Properties | List of all members
HybridBridge.BridgeController Class Reference

BridgeController is an abstract class containing a list of registered IBridgeHandler instances. This class should be extended for different environments. More...

Inheritance diagram for HybridBridge.BridgeController:
HybridBridge.Android.WebViewHybridBridge HybridBridge.iOS.UIWebViewHybridBridge HybridBridge.UWP.WebViewHybridBridge HybridBridge.WebServer.HybridBridgeLocalServer HybridBridge.Win81.WebViewHybridBridge HybridBridge.UWP.WebViewHybridServer HybridBridge.Win81.WebViewHybridServer HybridBridge.Win.WebBrowserHybridServer HybridBridge.Win.WPF.WebBrowserHybridServer

Public Member Functions

virtual IEnumerator< IBridgeHandlerGetEnumerator ()
 Returns the IEnumerator object for this class More...
 
void Add (IBridgeHandler item)
 Adds a new IBridgeHandler object to the list More...
 
void Clear ()
 Clears the list by removing all registered IBridgeHandler objects More...
 
virtual bool Contains (IBridgeHandler item)
 Goes through the list of registered IBridgeHandler objects and checks for existing of the passed instance More...
 
virtual void CopyTo (IBridgeHandler[] array, int arrayIndex)
 Copies the list of registered IBridgeHandler object to an array More...
 
bool Remove (IBridgeHandler item)
 Removes the passed instance of IBridgeHandler from the list of the registered handlers More...
 
virtual int IndexOf (IBridgeHandler item)
 Returns the index of the passed IBridgeHandler instance in the list More...
 
virtual void Insert (int index, IBridgeHandler item)
 Inserts and registers the passed instance of IBridgeHandler More...
 
virtual void RemoveAt (int index)
 Removed a IBridgeHandler instance at the specific index More...
 
virtual T Get< T > ()
 Returns a registered IBridgeHandler by type More...
 
virtual IBridgeHandler Get (Type type)
 Returns a registered IBridgeHandler by type More...
 
virtual object ExecuteJavascript (string jsCode)
 Executes a Javascript string and returns the result More...
 
virtual void ExecuteJavascript (string jsCode, Action< object > result)
 Executes a Javascript string and calls the passed callback for result More...
 
virtual void FireJavascript (string jsCode)
 Fires a Javascript string More...
 
virtual object CallJavascriptFunction (string methodName, params object[] arguments)
 Calls a Javascript method with the provided arguments and return the result More...
 
virtual void CallJavascriptAction (string methodName, params object[] arguments)
 Calls a Javascript method with the provided arguments and return the result More...
 
void AddRange (IEnumerable< IBridgeHandler > collection)
 Adds a list of IBridgeHandler instances to the list More...
 

Public Attributes

virtual int Count => Handlers.Count
 Returns the number of registered IBridgeHandler objects More...
 
virtual bool IsReadOnly => false
 Indicates if the list is read only More...
 

Protected Member Functions

 BridgeController (string customProtocol, IEnumerable< IBridgeHandler > collection)
 Creates a new instance of BridgeController class More...
 
 BridgeController (string customProtocol)
 Creates a new instance of BridgeController class More...
 
 BridgeController (IEnumerable< IBridgeHandler > collection)
 Creates a new instance of BridgeController class More...
 
 BridgeController ()
 Creates a new instance of BridgeController class More...
 
virtual string NormalizeCustomProtocol (string customProtocol=null)
 Makes sure that the passed custom protocol is acceptable and makes the necessarily changes More...
 
virtual void Initialize ()
 Executes the BridgeController javascript code More...
 
virtual bool HandleRequestUrl (string url)
 Handles a request and leaves the result behind More...
 
virtual bool HandleRequestUrl (string url, out bool hasResult, out object result)
 Handles a request More...
 
virtual void PushJavascript ()
 Generated the Javascript code for the BridgeController class as well as all the registered handlers More...
 
virtual object BridgeHandler_PushJavascript (IBridgeHandler sender, PushJavascriptEventArgs eventArgs)
 Passes Javascript requests from the IBridgeHandler instances to the browser More...
 

Protected Attributes

readonly List< IBridgeHandlerHandlers = new List<IBridgeHandler>()
 The underlying list of IBridgeHandler instances More...
 

Properties

virtual TimeSpan JavascriptTimeout [get, set]
 Sets or gets the time that we should wait for the result of any Javascript invocation, this value doesn't applies to callbacks More...
 
string Protocol = TimeSpan.FromSeconds(3) [get, protected set]
 The protocol to use for communication with web browser More...
 
virtual IBridgeHandler this[int index] [get, set]
 Set or get an IBridgeHandler instance by index More...
 

Detailed Description

BridgeController is an abstract class containing a list of registered IBridgeHandler instances. This class should be extended for different environments.

Definition at line 17 of file BridgeController.cs.

Constructor & Destructor Documentation

HybridBridge.BridgeController.BridgeController ( string  customProtocol,
IEnumerable< IBridgeHandler collection 
)
protected

Creates a new instance of BridgeController class

Parameters
customProtocolThe protocol to use for communication with web browser, or to use default
collectionList of all IBridgeHandler classes

Definition at line 34 of file BridgeController.cs.

HybridBridge.BridgeController.BridgeController ( string  customProtocol)
protected

Creates a new instance of BridgeController class

Parameters
customProtocolThe protocol to use for communication with web browser, or to use default

Definition at line 48 of file BridgeController.cs.

HybridBridge.BridgeController.BridgeController ( IEnumerable< IBridgeHandler collection)
protected

Creates a new instance of BridgeController class

Parameters
collectionList of all IBridgeHandler classes

Definition at line 56 of file BridgeController.cs.

HybridBridge.BridgeController.BridgeController ( )
protected

Creates a new instance of BridgeController class

Definition at line 63 of file BridgeController.cs.

Member Function Documentation

void HybridBridge.BridgeController.Add ( IBridgeHandler  item)

Adds a new IBridgeHandler object to the list

Parameters
itemThe IBridgeHandler object

Definition at line 105 of file BridgeController.cs.

void HybridBridge.BridgeController.AddRange ( IEnumerable< IBridgeHandler collection)

Adds a list of IBridgeHandler instances to the list

Parameters
collectionA list of IBridgeHandler instances

Definition at line 424 of file BridgeController.cs.

virtual object HybridBridge.BridgeController.BridgeHandler_PushJavascript ( IBridgeHandler  sender,
PushJavascriptEventArgs  eventArgs 
)
protectedvirtual

Passes Javascript requests from the IBridgeHandler instances to the browser

Parameters
senderThe IBridgeHandler asking for the Javascript execution
eventArgsThe arguments of this event
Returns

Definition at line 436 of file BridgeController.cs.

virtual void HybridBridge.BridgeController.CallJavascriptAction ( string  methodName,
params object[]  arguments 
)
virtual

Calls a Javascript method with the provided arguments and return the result

Parameters
methodNameThe name of the method to call
argumentsThe arguments to send to the method

Definition at line 308 of file BridgeController.cs.

virtual object HybridBridge.BridgeController.CallJavascriptFunction ( string  methodName,
params object[]  arguments 
)
virtual

Calls a Javascript method with the provided arguments and return the result

Parameters
methodNameThe name of the method to call
argumentsThe arguments to send to the method
Returns
Result of the code execution

Definition at line 296 of file BridgeController.cs.

void HybridBridge.BridgeController.Clear ( )

Clears the list by removing all registered IBridgeHandler objects

Definition at line 113 of file BridgeController.cs.

virtual bool HybridBridge.BridgeController.Contains ( IBridgeHandler  item)
virtual

Goes through the list of registered IBridgeHandler objects and checks for existing of the passed instance

Parameters
itemIBridgeHandler instance to search for
Returns
if the passed instance was in the list, otherwise

Definition at line 125 of file BridgeController.cs.

virtual void HybridBridge.BridgeController.CopyTo ( IBridgeHandler[]  array,
int  arrayIndex 
)
virtual

Copies the list of registered IBridgeHandler object to an array

Parameters
arrayArray to copy the list to
arrayIndexIndex of first element in the destination array

Definition at line 135 of file BridgeController.cs.

virtual object HybridBridge.BridgeController.ExecuteJavascript ( string  jsCode)
virtual

Executes a Javascript string and returns the result

Parameters
jsCodeThe code to execute
Returns
Result of the code execution

Definition at line 258 of file BridgeController.cs.

virtual void HybridBridge.BridgeController.ExecuteJavascript ( string  jsCode,
Action< object >  result 
)
virtual

Executes a Javascript string and calls the passed callback for result

Parameters
jsCodeThe code to execute
resultThe callback to be called with the result of the execution

Reimplemented in HybridBridge.UWP.WebViewHybridBridge, HybridBridge.Win81.WebViewHybridBridge, HybridBridge.iOS.UIWebViewHybridBridge, HybridBridge.Android.WebViewHybridBridge, HybridBridge.UWP.WebViewHybridServer, HybridBridge.Win81.WebViewHybridServer, HybridBridge.Win.WPF.WebBrowserHybridServer, and HybridBridge.Win.WebBrowserHybridServer.

Definition at line 276 of file BridgeController.cs.

virtual void HybridBridge.BridgeController.FireJavascript ( string  jsCode)
virtual

Fires a Javascript string

Parameters
jsCodeThe code to execute

Definition at line 285 of file BridgeController.cs.

virtual IBridgeHandler HybridBridge.BridgeController.Get ( Type  type)
virtual

Returns a registered IBridgeHandler by type

Parameters
typeThe type of IBridgeHandler to return
Returns
The IBridgeHandler instance of the specified type

Definition at line 248 of file BridgeController.cs.

virtual T HybridBridge.BridgeController.Get< T > ( )
virtual

Returns a registered IBridgeHandler by type

Template Parameters
TThe type of IBridgeHandler to return
Returns
The IBridgeHandler instance of the specified type

Definition at line 238 of file BridgeController.cs.

virtual IEnumerator<IBridgeHandler> HybridBridge.BridgeController.GetEnumerator ( )
virtual

Returns the IEnumerator object for this class

Returns
IEnumerator object for this class

Definition at line 86 of file BridgeController.cs.

virtual bool HybridBridge.BridgeController.HandleRequestUrl ( string  url)
protectedvirtual

Handles a request and leaves the result behind

Parameters
urlThe Url to handle
Returns
if the Url handled, otherwise

Definition at line 360 of file BridgeController.cs.

virtual bool HybridBridge.BridgeController.HandleRequestUrl ( string  url,
out bool  hasResult,
out object  result 
)
protectedvirtual

Handles a request

Parameters
urlThe Url to handle
hasResultAn outgoing boolean parameter indicating if the handling of the passed Url generated a result
resultAn outgoing object containing the result of the handling process
Returns
if the Url handled, otherwise

Definition at line 374 of file BridgeController.cs.

virtual int HybridBridge.BridgeController.IndexOf ( IBridgeHandler  item)
virtual

Returns the index of the passed IBridgeHandler instance in the list

Parameters
itemIBridgeHandler instance to search for
Returns
Index of the passed instance, otherwise -1

Definition at line 171 of file BridgeController.cs.

virtual void HybridBridge.BridgeController.Initialize ( )
protectedvirtual

Executes the BridgeController javascript code

Definition at line 316 of file BridgeController.cs.

virtual void HybridBridge.BridgeController.Insert ( int  index,
IBridgeHandler  item 
)
virtual

Inserts and registers the passed instance of IBridgeHandler

Parameters
indexIndex to which the new instance should be added
itemThe instance of IBridgeHandler
Exceptions
RedundantHandlerExceptionAn instance of the same type in already in list

Definition at line 182 of file BridgeController.cs.

virtual string HybridBridge.BridgeController.NormalizeCustomProtocol ( string  customProtocol = null)
protectedvirtual

Makes sure that the passed custom protocol is acceptable and makes the necessarily changes

Reimplemented in HybridBridge.UWP.WebViewHybridBridge, HybridBridge.Win81.WebViewHybridBridge, and HybridBridge.WebServer.HybridBridgeLocalServer.

Definition at line 221 of file BridgeController.cs.

virtual void HybridBridge.BridgeController.PushJavascript ( )
protectedvirtual

Generated the Javascript code for the BridgeController class as well as all the registered handlers

Definition at line 413 of file BridgeController.cs.

bool HybridBridge.BridgeController.Remove ( IBridgeHandler  item)

Removes the passed instance of IBridgeHandler from the list of the registered handlers

Parameters
itemThe IBridgeHandler instance to remove from the list
Returns
if desired instance removed from the list, otherwise

Definition at line 147 of file BridgeController.cs.

virtual void HybridBridge.BridgeController.RemoveAt ( int  index)
virtual

Removed a IBridgeHandler instance at the specific index

Parameters
indexIndex of the instance to remove

Definition at line 194 of file BridgeController.cs.

Member Data Documentation

virtual int HybridBridge.BridgeController.Count => Handlers.Count

Returns the number of registered IBridgeHandler objects

Definition at line 159 of file BridgeController.cs.

readonly List<IBridgeHandler> HybridBridge.BridgeController.Handlers = new List<IBridgeHandler>()
protected

The underlying list of IBridgeHandler instances

Definition at line 22 of file BridgeController.cs.

virtual bool HybridBridge.BridgeController.IsReadOnly => false

Indicates if the list is read only

Definition at line 164 of file BridgeController.cs.

Property Documentation

virtual TimeSpan HybridBridge.BridgeController.JavascriptTimeout
getset

Sets or gets the time that we should wait for the result of any Javascript invocation, this value doesn't applies to callbacks

Definition at line 71 of file BridgeController.cs.

string HybridBridge.BridgeController.Protocol = TimeSpan.FromSeconds(3)
getprotected set

The protocol to use for communication with web browser

Definition at line 77 of file BridgeController.cs.

virtual IBridgeHandler HybridBridge.BridgeController.this[int index]
getset

Set or get an IBridgeHandler instance by index

Parameters
indexIndex of the IBridgeHandler instance

Definition at line 206 of file BridgeController.cs.


The documentation for this class was generated from the following file: