\r\n

51Degrees Pipeline .NET  4.4

51Degrees Pipeline for .NET

FiftyOne.Pipeline.JavaScriptBuilder.FlowElement.JavaScriptBuilderElement Class Reference

Detailed Description

JavaScript Builder Element generates a JavaScript include to be run on the client device.

See the Specification

Inheritance diagram for FiftyOne.Pipeline.JavaScriptBuilder.FlowElement.JavaScriptBuilderElement:

[legend]

Collaboration diagram for FiftyOne.Pipeline.JavaScriptBuilder.FlowElement.JavaScriptBuilderElement:

[legend]

Public Member Functions

 JavaScriptBuilderElement (ILogger< JavaScriptBuilderElement > logger, Func< IPipeline, FlowElementBase< IJavaScriptBuilderElementData, IElementPropertyMetaData >, IJavaScriptBuilderElementData > elementDataFactory, string endpoint, string objectName, bool enableCookies, bool minify, string host=null, string protocol=null)
Default constructor. More...
IJavaScriptBuilderElementData  GetFallbackResponse (IFlowData data, IJsonBuilderElementData jsonData)
Default process method. More...

Public Member Functions inherited from FiftyOne.Pipeline.Core.FlowElements.FlowElementBase< IJavaScriptBuilderElementData, IElementPropertyMetaData >

 FlowElementBase (ILogger< FlowElementBase< T, TMeta >> logger)
Constructor More...
 FlowElementBase (ILogger< FlowElementBase< T, TMeta >> logger, Func< IPipeline, FlowElementBase< T, TMeta >, T > elementDataFactory)
Constructor More...
virtual void  Process (IFlowData data)
Process the given IFlowData with this FlowElement. More...
virtual void  AddPipeline (IPipeline pipeline)
Called when this element is added to a pipeline. More...
void  Dispose ()
Dispose More...

Public Attributes

const string  DEFAULT_ELEMENT_DATA_KEY = "javascriptbuilderelement"
The default element data key that will be used for this element. More...
override string  ElementDataKey => DEFAULT_ELEMENT_DATA_KEY
Key to identify engine. More...
override IEvidenceKeyFilter  EvidenceKeyFilter
Publicly accessible EvidenceKeyFilter More...
override IList< IElementPropertyMetaData >  Properties
Publicly accessible Property list. More...

Protected Member Functions

override void  ManagedResourcesCleanup ()
Cleanup any managed resources. More...
override void  ProcessInternal (IFlowData data)
Default process method. More...
virtual Dictionary< string, string >  GetParameters (IFlowData data)
Generate any required parameters for the JSON request. More...
virtual int  GetSequence (IFlowData data)
Get the sequence evidence if it exists. More...
virtual string  GetSessionId (IFlowData data)
Get the session-id evidence if it exists. More...
void  BuildJavaScript (IFlowData data, Func< IJavaScriptBuilderElementData > javascriptBuilderElementDataProvider, string jsonObject, string sessionId, int sequence, bool supportsPromises, bool supportsFetch, string url, string parameters)
Build the JavaScript content and add it to the supplied IFlowData instance. More...
Func< IJavaScriptBuilderElementData >  GetOrAddToData (IFlowData data)
Delegates to IFlowData.GetOrAdd<T>(string, Func<IPipeline, T>). More...
void  BuildJavaScript (IFlowData data, Func< IJavaScriptBuilderElementData > javascriptBuilderElementDataProvider, string jsonObject, string sessionId, int sequence, bool supportsPromises, bool supportsFetch, Uri url, string parameters)
Build the JavaScript content and add it to the supplied IFlowData instance. More...
void  BuildJavaScript (IFlowData data, string jsonObject, string sessionId, int sequence, bool supportsPromises, bool supportsFetch, Uri url, string parameters)
Build the JavaScript content and add it to the supplied IFlowData instance. More...
override void  UnmanagedResourcesCleanup ()
Cleanup any unmanaged resources. More...

Protected Member Functions inherited from FiftyOne.Pipeline.Core.FlowElements.FlowElementBase< IJavaScriptBuilderElementData, IElementPropertyMetaData >

abstract void  ProcessInternal (IFlowData data)
Abstract method called by Process(IFlowData). More...
virtual T  CreateElementData (IPipeline pipeline)
Method used to create element data instances that are populated by this flow element More...
virtual void  Dispose (bool disposing)
Dispose of any resources. More...

Static Protected Member Functions

static Func< IJsonBuilderElementData >  GetJSONFromData (IFlowData flowData)
Attempts to extract IJsonBuilderElementData from data. More...

Properties

string  Host [get]
The host name to use when creating a callback URL. More...
string  Endpoint [get]
The end point (i.e. More...
string  Protocol [get]
The protocol to use when creating a callback URL. More...
string  ObjName [get]
The name of the JavaScript object that will be created. More...
bool  EnableCookies [get]
If set to false, the JavaScript will automatically delete any cookies prefixed with 51D_ More...
HashSet< string >  ExcludedParameters [get]
These parameters are excluded from the parameters object used to configure the JavaScript as they are added explicitly. More...

Properties inherited from FiftyOne.Pipeline.Core.FlowElements.FlowElementBase< IJavaScriptBuilderElementData, IElementPropertyMetaData >

ILogger< FlowElementBase< T, TMeta > >  Logger [get]
The logger for this instance More...
IReadOnlyList< IPipeline >  Pipelines [get]
Get a read only list of the pipelines that this element has been added to. More...
abstract string  ElementDataKey [get]
The string name of the key used to access the data populated by this element in the IFlowData. More...
abstract IEvidenceKeyFilter  EvidenceKeyFilter [get]
A list of all the evidence keys that this Flow Element can make use of. More...
abstract IList< TMeta >  Properties [get]
Details of the properties that this engine can populate More...
virtual bool  Asynchronous [get]
True if the element can be run totally asynchronously, false otherwise. More...
virtual bool  IsConcurrent [get]
True if the element starts multiple threads. More...
bool  IsDisposed [get]
True if the element has been disposed More...
ITypedKey< T >  ElementDataKeyTyped [get]
Get the key used to access the data populated by this element in the IFlowData. More...

Constructor & Destructor Documentation

◆ JavaScriptBuilderElement()

FiftyOne.Pipeline.JavaScriptBuilder.FlowElement.JavaScriptBuilderElement.JavaScriptBuilderElement ( ILogger< JavaScriptBuilderElement >   logger,
Func< IPipeline, FlowElementBase< IJavaScriptBuilderElementData, IElementPropertyMetaData >, IJavaScriptBuilderElementData >   elementDataFactory,
string   endpoint,
string   objectName,
bool   enableCookies,
bool   minify,
string   host = null,
string   protocol = null  
)

Default constructor.

Parameters
logger - The logger.
elementDataFactory - The element data factory.
endpoint - Set the endpoint which will be queried on the host. e.g /api/v4/json
objectName - The default name of the object instantiated by the client JavaScript.
enableCookies - Set whether the client JavaScript stored results of client side processing in cookies.
minify - If true, the resulting JavaScript will be minified
host - The host that the client JavaScript should query for updates. If null or blank then the host from the request will be used
protocol - The protocol (HTTP or HTTPS) that the client JavaScript will use when querying for updates. If null or blank then the protocol from the request will be used

Member Function Documentation

◆ BuildJavaScript() [1/3]

void FiftyOne.Pipeline.JavaScriptBuilder.FlowElement.JavaScriptBuilderElement.BuildJavaScript ( IFlowData   data,
Func< IJavaScriptBuilderElementData >   javascriptBuilderElementDataProvider,
string   jsonObject,
string   sessionId,
int   sequence,
bool   supportsPromises,
bool   supportsFetch,
string   url,
string   parameters  
)
protected

Build the JavaScript content and add it to the supplied IFlowData instance.

Parameters
data - The IFlowData instance to populate with the resulting JavaScriptBuilderElementData and additional evidence source
javascriptBuilderElementDataProvider - Defines a destination for JavaScriptBuilderElementData to be set into. Allows to store results outside of data (previous parameter).
jsonObject - The JSON data object to include in the JavaScript.
sessionId - The session Id to use in the JavaScript response.
sequence - The sequence value to use in the JavaScript response.
supportsPromises - True to build JavaScript that uses promises. False to build JavaScript that does not use promises.
supportsFetch - True to build JavaScript that makes use of the fetch API. Otherwise, the template will fall back to using XMLHttpRequest.
url - The callback URL for the JavaScript to send a request to when it has new evidence values to supply.
parameters - The parameters to append to the URL
Exceptions
ArgumentNullException - Thrown if the supplied flow data is null.

◆ BuildJavaScript() [2/3]

void FiftyOne.Pipeline.JavaScriptBuilder.FlowElement.JavaScriptBuilderElement.BuildJavaScript ( IFlowData   data,
Func< IJavaScriptBuilderElementData >   javascriptBuilderElementDataProvider,
string   jsonObject,
string   sessionId,
int   sequence,
bool   supportsPromises,
bool   supportsFetch,
Uri   url,
string   parameters  
)
protected

Build the JavaScript content and add it to the supplied IFlowData instance.

Parameters
data - The IFlowData instance to populate with the resulting JavaScriptBuilderElementData and additional evidence source
javascriptBuilderElementDataProvider - Defines a destination for JavaScriptBuilderElementData to be set into. Allows to store results outside of data (previous parameter).
jsonObject - The JSON data object to include in the JavaScript.
sessionId - The session Id to use in the JavaScript response.
sequence - The sequence value to use in the JavaScript response.
supportsPromises - True to build JavaScript that uses promises. False to build JavaScript that does not use promises.
supportsFetch - True to build JavaScript that makes use of the fetch API. Otherwise, the template will fall back to using XMLHttpRequest.
url - The callback URL for the JavaScript to send a request to when it has new evidence values to supply.
parameters - The parameters to append to the URL
Exceptions
ArgumentNullException - Thrown if the supplied flow data is null.

◆ BuildJavaScript() [3/3]

void FiftyOne.Pipeline.JavaScriptBuilder.FlowElement.JavaScriptBuilderElement.BuildJavaScript ( IFlowData   data,
string   jsonObject,
string   sessionId,
int   sequence,
bool   supportsPromises,
bool   supportsFetch,
Uri   url,
string   parameters  
)
protected

Build the JavaScript content and add it to the supplied IFlowData instance.

Parameters
data - The IFlowData instance to populate with the resulting JavaScriptBuilderElementData and additional evidence source
jsonObject - The JSON data object to include in the JavaScript.
sessionId - The session Id to use in the JavaScript response.
sequence - The sequence value to use in the JavaScript response.
supportsPromises - True to build JavaScript that uses promises. False to build JavaScript that does not use promises.
supportsFetch - True to build JavaScript that makes use of the fetch API. Otherwise, the template will fall back to using XMLHttpRequest.
url - The callback URL for the JavaScript to send a request to when it has new evidence values to supply.
parameters - The parameters to append to the URL
Exceptions
ArgumentNullException - Thrown if the supplied flow data is null.

◆ GetFallbackResponse()

IJavaScriptBuilderElementData FiftyOne.Pipeline.JavaScriptBuilder.FlowElement.JavaScriptBuilderElement.GetFallbackResponse ( IFlowData   data,
IJsonBuilderElementData   jsonData  
)

Default process method.

Parameters
data -
jsonData -
Exceptions
ArgumentNullException - Thrown if the supplied flow data is null.

◆ GetJSONFromData()

static Func<IJsonBuilderElementData> FiftyOne.Pipeline.JavaScriptBuilder.FlowElement.JavaScriptBuilderElement.GetJSONFromData ( IFlowData   flowData )
static protected

Attempts to extract IJsonBuilderElementData from data.

Parameters
flowData - IFlowData to extract IJsonBuilderElementData from.
Exceptions
ArgumentNullException - Thrown if the supplied flow data is null.
PipelineConfigurationException - Wraps KeyNotFoundException if thrown.

◆ GetOrAddToData()

Func<IJavaScriptBuilderElementData> FiftyOne.Pipeline.JavaScriptBuilder.FlowElement.JavaScriptBuilderElement.GetOrAddToData ( IFlowData   data )
protected

Delegates to IFlowData.GetOrAdd<T>(string, Func<IPipeline, T>).

Parameters
data - Flow data to operate on.
Returns
IJavaScriptBuilderElementData to set IJavaScriptBuilderElementData.JavaScript into.

◆ GetParameters()

virtual Dictionary<string, string> FiftyOne.Pipeline.JavaScriptBuilder.FlowElement.JavaScriptBuilderElement.GetParameters ( IFlowData   data )
protected virtual

Generate any required parameters for the JSON request.

Any query parameters from this request that were ingested by the Pipeline are added to the request URL by the JavaScript.

Parameters
data -
Returns

◆ GetSequence()

virtual int FiftyOne.Pipeline.JavaScriptBuilder.FlowElement.JavaScriptBuilderElement.GetSequence ( IFlowData   data )
protected virtual

Get the sequence evidence if it exists.

Parameters
data -
Returns

◆ GetSessionId()

virtual string FiftyOne.Pipeline.JavaScriptBuilder.FlowElement.JavaScriptBuilderElement.GetSessionId ( IFlowData   data )
protected virtual

Get the session-id evidence if it exists.

Parameters
data -
Returns

◆ ProcessInternal()

override void FiftyOne.Pipeline.JavaScriptBuilder.FlowElement.JavaScriptBuilderElement.ProcessInternal ( IFlowData   data )
protected

Default process method.

Parameters
data -
Exceptions
ArgumentNullException - Thrown if the supplied flow data is null.

Member Data Documentation

◆ DEFAULT_ELEMENT_DATA_KEY

const string FiftyOne.Pipeline.JavaScriptBuilder.FlowElement.JavaScriptBuilderElement.DEFAULT_ELEMENT_DATA_KEY = "javascriptbuilderelement"

The default element data key that will be used for this element.

◆ ElementDataKey

override string FiftyOne.Pipeline.JavaScriptBuilder.FlowElement.JavaScriptBuilderElement.ElementDataKey => DEFAULT_ELEMENT_DATA_KEY

Key to identify engine.

◆ EvidenceKeyFilter

override IEvidenceKeyFilter FiftyOne.Pipeline.JavaScriptBuilder.FlowElement.JavaScriptBuilderElement.EvidenceKeyFilter
Initial value:
=>
_evidenceKeyFilter

Publicly accessible EvidenceKeyFilter

◆ Properties

override IList<IElementPropertyMetaData> FiftyOne.Pipeline.JavaScriptBuilder.FlowElement.JavaScriptBuilderElement.Properties
Initial value:
=>
_properties

Publicly accessible Property list.

Property Documentation

◆ EnableCookies

bool FiftyOne.Pipeline.JavaScriptBuilder.FlowElement.JavaScriptBuilderElement.EnableCookies
get protected

If set to false, the JavaScript will automatically delete any cookies prefixed with 51D_

◆ Endpoint

string FiftyOne.Pipeline.JavaScriptBuilder.FlowElement.JavaScriptBuilderElement.Endpoint
get protected

The end point (i.e.

the relative URL) to use when creating a callback URL.

◆ ExcludedParameters

HashSet<string> FiftyOne.Pipeline.JavaScriptBuilder.FlowElement.JavaScriptBuilderElement.ExcludedParameters
get protected
Initial value:
= new HashSet<string>()
{
Engines.FiftyOne.Constants.EVIDENCE_SEQUENCE,
Engines.FiftyOne.Constants.EVIDENCE_SESSIONID,
}

These parameters are excluded from the parameters object used to configure the JavaScript as they are added explicitly.

◆ Host

string FiftyOne.Pipeline.JavaScriptBuilder.FlowElement.JavaScriptBuilderElement.Host
get protected

The host name to use when creating a callback URL.

◆ ObjName

string FiftyOne.Pipeline.JavaScriptBuilder.FlowElement.JavaScriptBuilderElement.ObjName
get protected

The name of the JavaScript object that will be created.

◆ Protocol

string FiftyOne.Pipeline.JavaScriptBuilder.FlowElement.JavaScriptBuilderElement.Protocol
get protected

The protocol to use when creating a callback URL.