\r\n

51Degrees Pipeline .NET  4.4

51Degrees Pipeline for .NET

FiftyOne.Pipeline.Engines.FiftyOne.FlowElements.ShareUsageBase Class Reference abstract

Detailed Description

Abstract base class for ShareUsage elements.

See the Specification

Inheritance diagram for FiftyOne.Pipeline.Engines.FiftyOne.FlowElements.ShareUsageBase:

[legend]

Collaboration diagram for FiftyOne.Pipeline.Engines.FiftyOne.FlowElements.ShareUsageBase:

[legend]

Classes

class  ShareUsageData
Inner class that is used to store details of data in memory prior to it being sent to 51Degrees. More...

Public Member Functions

override void  AddPipeline (IPipeline pipeline)
Add More...
string  EncodeInvalidXMLChars (string text, ref bool flagBadSchema)
encodes any unusual characters into their hex representation More...

Public Member Functions inherited from FiftyOne.Pipeline.Core.FlowElements.FlowElementBase< IElementData, 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...
void  Dispose ()
Dispose More...

Public Attributes

const string  DEFAULT_ELEMENT_DATA_KEY = "shareusage"
The default element data key that will be used for this element. More...
override string  ElementDataKey => DEFAULT_ELEMENT_DATA_KEY
The data key for this element More...

Protected Member Functions

 ShareUsageBase (ILogger< ShareUsageBase > logger, HttpClient httpClient, double sharePercentage, int minimumEntriesPerMessage, int maximumQueueSize, int addTimeout, int takeTimeout, int repeatEvidenceIntervalMinutes, bool trackSession, string shareUsageUrl, List< string > blockedHttpHeaders, List< string > includedQueryStringParameters, List< KeyValuePair< string, string >> ignoreDataEvidenceFilter, string aspSessionCookieName=Engines.Constants.DEFAULT_ASP_COOKIE_NAME)
Constructor More...
 ShareUsageBase (ILogger< ShareUsageBase > logger, HttpClient httpClient, double sharePercentage, int minimumEntriesPerMessage, int maximumQueueSize, int addTimeout, int takeTimeout, int repeatEvidenceIntervalMinutes, bool trackSession, string shareUsageUrl, List< string > blockedHttpHeaders, List< string > includedQueryStringParameters, List< KeyValuePair< string, string >> ignoreDataEvidenceFilter, string aspSessionCookieName, ITracker tracker)
Constructor More...
 ShareUsageBase (ILogger< ShareUsageBase > logger, HttpClient httpClient, double sharePercentage, int minimumEntriesPerMessage, int maximumQueueSize, int addTimeout, int takeTimeout, int repeatEvidenceIntervalMinutes, bool trackSession, string shareUsageUrl, List< string > blockedHttpHeaders, List< string > includedQueryStringParameters, List< KeyValuePair< string, string >> ignoreDataEvidenceFilter, string aspSessionCookieName, ITracker tracker, bool shareAllEvidence)
Constructor More...
override void  ProcessInternal (IFlowData data)
Process the data More...
override void  ManagedResourcesCleanup ()
Send any data which has built up locally and not yet been sent to the remote service. More...
override void  UnmanagedResourcesCleanup ()
Clean up any unmanaged resources. More...
void  TrySendData ()
Attempt to send the data to the remote service. More...
abstract void  BuildAndSendXml ()
virtual void  WriteData (XmlWriter writer, ShareUsageData data)
Virtual method to be overridden in extending usage share elements. More...
void  WriteDeviceData (XmlWriter writer, ShareUsageData data)
Write the specified device data using the specified writer. More...
virtual void  WritePipelineInfo (XmlWriter writer)
Virtual method to write details about the pipeline. More...

Protected Member Functions inherited from FiftyOne.Pipeline.Core.FlowElements.FlowElementBase< IElementData, 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...

Protected Attributes

HttpClient  HttpClient => _httpClient
The HttpClient to use when sending the data. More...
string  ShareUsageUrl => ShareUsageUri.AbsoluteUri
The base URL to send usage data to. More...

Properties

BlockingCollection< ShareUsageData >  EvidenceCollection [get]
Queue used to store entries in memory prior to them being sent to 51Degrees. More...
int  TakeTimeout [get]
Timeout to use when taking from the queue. More...
int  MinEntriesPerMessage = Constants.SHARE_USAGE_DEFAULT_MIN_ENTRIES_PER_MESSAGE [get]
The minimum number of request entries per message sent to 51Degrees. More...
Uri  ShareUsageUri [get]
The base URL to send usage data to. More...
XmlWriterSettings  WriterSettings [get]
The settings to use when creating an XML payload to send to the usage sharing web service. More...
override IEvidenceKeyFilter  EvidenceKeyFilter [get]
Get the evidence key filter for this element. More...
string?  HostAddress [get]
Get the IP address of the machine that this code is running on. More...
override IList< IElementPropertyMetaData >  Properties [get]
Get a list of the meta-data relating to the properties that this flow element will populate. More...
internal bool  IsCanceled = false [get, set]
Indicates whether share usage has been canceled as a result of an error. More...

Properties inherited from FiftyOne.Pipeline.Core.FlowElements.FlowElementBase< IElementData, 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

◆ ShareUsageBase() [1/3]

FiftyOne.Pipeline.Engines.FiftyOne.FlowElements.ShareUsageBase.ShareUsageBase ( ILogger< ShareUsageBase >   logger,
HttpClient   httpClient,
double   sharePercentage,
int   minimumEntriesPerMessage,
int   maximumQueueSize,
int   addTimeout,
int   takeTimeout,
int   repeatEvidenceIntervalMinutes,
bool   trackSession,
string   shareUsageUrl,
List< string >   blockedHttpHeaders,
List< string >   includedQueryStringParameters,
List< KeyValuePair< string, string >>   ignoreDataEvidenceFilter,
string   aspSessionCookieName = Engines.Constants.DEFAULT_ASP_COOKIE_NAME  
)
protected

Constructor

Parameters
logger - The logger to use.
httpClient - The HttpClient to use when sending request data.
sharePercentage - The approximate proportion of requests to share. 1 = 100%, 0.5 = 50%, etc.
minimumEntriesPerMessage - The minimum number of request entries per message sent to 51Degrees.
maximumQueueSize - The maximum number of items to hold in the queue at one time. This must be larger than minimum entries.
addTimeout - The timeout in milliseconds to allow when attempting to add an item to the queue. If this timeout is exceeded then usage sharing will be disabled.
takeTimeout - The timeout in milliseconds to allow when attempting to take an item to the queue.
repeatEvidenceIntervalMinutes - The interval (in minutes) which is used to decide if repeat evidence is old enough to consider a new session.
trackSession - Set if the tracker should consider sessions in share usage.
shareUsageUrl - The URL to send data to
blockedHttpHeaders - A list of the names of the HTTP headers that share usage should not send to 51Degrees.
includedQueryStringParameters - A list of the names of query string parameters that share usage should send to 51Degrees. If this value is null, all query string parameters are shared.
ignoreDataEvidenceFilter -
aspSessionCookieName - The name of the cookie that contains the asp.net session id.

◆ ShareUsageBase() [2/3]

FiftyOne.Pipeline.Engines.FiftyOne.FlowElements.ShareUsageBase.ShareUsageBase ( ILogger< ShareUsageBase >   logger,
HttpClient   httpClient,
double   sharePercentage,
int   minimumEntriesPerMessage,
int   maximumQueueSize,
int   addTimeout,
int   takeTimeout,
int   repeatEvidenceIntervalMinutes,
bool   trackSession,
string   shareUsageUrl,
List< string >   blockedHttpHeaders,
List< string >   includedQueryStringParameters,
List< KeyValuePair< string, string >>   ignoreDataEvidenceFilter,
string   aspSessionCookieName,
ITracker   tracker  
)
protected

Constructor

Parameters
logger - The logger to use.
httpClient - The HttpClient to use when sending request data.
sharePercentage - The approximate proportion of requests to share. 1 = 100%, 0.5 = 50%, etc.
minimumEntriesPerMessage - The minimum number of request entries per message sent to 51Degrees.
maximumQueueSize - The maximum number of items to hold in the queue at one time. This must be larger than minimum entries.
addTimeout - The timeout in milliseconds to allow when attempting to add an item to the queue. If this timeout is exceeded then usage sharing will be disabled.
takeTimeout - The timeout in milliseconds to allow when attempting to take an item to the queue.
repeatEvidenceIntervalMinutes - The interval (in minutes) which is used to decide if repeat evidence is old enough to consider a new session.
trackSession - Set if the tracker should consider sessions in share usage.
shareUsageUrl - The URL to send data to
blockedHttpHeaders - A list of the names of the HTTP headers that share usage should not send to 51Degrees.
includedQueryStringParameters - A list of the names of query string parameters that share usage should send to 51Degrees. If this value is null, all query string parameters are shared.
ignoreDataEvidenceFilter -
aspSessionCookieName - The name of the cookie that contains the asp.net session id.
tracker - The ITracker to use to determine if a given IFlowData instance should be shared or not.

◆ ShareUsageBase() [3/3]

FiftyOne.Pipeline.Engines.FiftyOne.FlowElements.ShareUsageBase.ShareUsageBase ( ILogger< ShareUsageBase >   logger,
HttpClient   httpClient,
double   sharePercentage,
int   minimumEntriesPerMessage,
int   maximumQueueSize,
int   addTimeout,
int   takeTimeout,
int   repeatEvidenceIntervalMinutes,
bool   trackSession,
string   shareUsageUrl,
List< string >   blockedHttpHeaders,
List< string >   includedQueryStringParameters,
List< KeyValuePair< string, string >>   ignoreDataEvidenceFilter,
string   aspSessionCookieName,
ITracker   tracker,
bool   shareAllEvidence  
)
protected

Constructor

Parameters
logger - The logger to use.
httpClient - HttpClient to use when sending request data.
sharePercentage - The approximate proportion of requests to share. 1 = 100%, 0.5 = 50%, etc.
minimumEntriesPerMessage - The minimum number of request entries per message sent to 51Degrees.
maximumQueueSize - The maximum number of items to hold in the queue at one time. This must be larger than minimum entries.
addTimeout - The timeout in milliseconds to allow when attempting to add an item to the queue. If this timeout is exceeded then usage sharing will be disabled.
takeTimeout - The timeout in milliseconds to allow when attempting to take an item to the queue.
repeatEvidenceIntervalMinutes - The interval (in minutes) which is used to decide if repeat evidence is old enough to consider a new session.
trackSession - Set if the tracker should consider sessions in share usage.
shareUsageUrl - The URL to send data to
blockedHttpHeaders - A list of the names of the HTTP headers that share usage should not send to 51Degrees.
includedQueryStringParameters - A list of the names of query string parameters that share usage should send to 51Degrees. If this value is null, all query string parameters are shared.
ignoreDataEvidenceFilter -
aspSessionCookieName - The name of the cookie that contains the asp.net session id.
tracker - The ITracker to use to determine if a given IFlowData instance should be shared or not.
shareAllEvidence - If true, all evidence will be shared and

the blockedHttpHeaders, includedQueryStringParameters and ignoreDataEvidenceFilter parameters will be ignored.

Exceptions
ArgumentNullException - Thrown if certain arguments are null.
ArgumentException - Thrown if certain argument values are invalid.

Member Function Documentation

◆ EncodeInvalidXMLChars()

string FiftyOne.Pipeline.Engines.FiftyOne.FlowElements.ShareUsageBase.EncodeInvalidXMLChars ( string   text,
ref bool   flagBadSchema  
)

encodes any unusual characters into their hex representation

Parameters
text - The text to encode
flagBadSchema - A flag storing whether this usage message inculdes any invalid characters that we have had to encod.
Returns
The encoded version of text
Exceptions
ArgumentNullException - Thrown if the supplied text is null

◆ ProcessInternal()

override void FiftyOne.Pipeline.Engines.FiftyOne.FlowElements.ShareUsageBase.ProcessInternal ( IFlowData   data )
protected

Process the data

Parameters
data - The IFlowData instance that provides the evidence
Exceptions
ArgumentNullException - Thrown if the supplied data instance is null

◆ TrySendData()

void FiftyOne.Pipeline.Engines.FiftyOne.FlowElements.ShareUsageBase.TrySendData ( )
protected

Attempt to send the data to the remote service.

This only happens if there is not a task already running.

If any error occurs while sending the data, then usage sharing is stopped.

Returns

◆ WriteData()

virtual void FiftyOne.Pipeline.Engines.FiftyOne.FlowElements.ShareUsageBase.WriteData ( XmlWriter   writer,
ShareUsageData   data  
)
protected virtual

Virtual method to be overridden in extending usage share elements.

Write the specified data using the specified writer.

Parameters
writer - The XmlWriter to use.
data - The ShareUsageData to write.
Exceptions
ArgumentNullException - Thrown if the supplied arguments are null

◆ WriteDeviceData()

void FiftyOne.Pipeline.Engines.FiftyOne.FlowElements.ShareUsageBase.WriteDeviceData ( XmlWriter   writer,
ShareUsageData   data  
)
protected

Write the specified device data using the specified writer.

Parameters
writer - The XmlWriter to use.
data - The ShareUsageData to write.
Exceptions
ArgumentNullException - Thrown if the supplied arguments are null

◆ WritePipelineInfo()

virtual void FiftyOne.Pipeline.Engines.FiftyOne.FlowElements.ShareUsageBase.WritePipelineInfo ( XmlWriter   writer )
protected virtual

Virtual method to write details about the pipeline.

Exceptions
ArgumentNullException - Thrown if the supplied writer is null

Member Data Documentation

◆ DEFAULT_ELEMENT_DATA_KEY

const string FiftyOne.Pipeline.Engines.FiftyOne.FlowElements.ShareUsageBase.DEFAULT_ELEMENT_DATA_KEY = "shareusage"

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

◆ ElementDataKey

override string FiftyOne.Pipeline.Engines.FiftyOne.FlowElements.ShareUsageBase.ElementDataKey => DEFAULT_ELEMENT_DATA_KEY

The data key for this element

◆ HttpClient

HttpClient FiftyOne.Pipeline.Engines.FiftyOne.FlowElements.ShareUsageBase.HttpClient => _httpClient
protected

The HttpClient to use when sending the data.

◆ ShareUsageUrl

string FiftyOne.Pipeline.Engines.FiftyOne.FlowElements.ShareUsageBase.ShareUsageUrl => ShareUsageUri.AbsoluteUri
protected

The base URL to send usage data to.

Property Documentation

◆ EvidenceCollection

BlockingCollection<ShareUsageData> FiftyOne.Pipeline.Engines.FiftyOne.FlowElements.ShareUsageBase.EvidenceCollection
get protected

Queue used to store entries in memory prior to them being sent to 51Degrees.

◆ EvidenceKeyFilter

override IEvidenceKeyFilter FiftyOne.Pipeline.Engines.FiftyOne.FlowElements.ShareUsageBase.EvidenceKeyFilter
get

Get the evidence key filter for this element.

◆ HostAddress

string? FiftyOne.Pipeline.Engines.FiftyOne.FlowElements.ShareUsageBase.HostAddress
get protected

Get the IP address of the machine that this code is running on.

◆ IsCanceled

internal bool FiftyOne.Pipeline.Engines.FiftyOne.FlowElements.ShareUsageBase.IsCanceled = false
get set protected

Indicates whether share usage has been canceled as a result of an error.

◆ MinEntriesPerMessage

int FiftyOne.Pipeline.Engines.FiftyOne.FlowElements.ShareUsageBase.MinEntriesPerMessage = Constants.SHARE_USAGE_DEFAULT_MIN_ENTRIES_PER_MESSAGE
get protected

The minimum number of request entries per message sent to 51Degrees.

◆ Properties

override IList<IElementPropertyMetaData> FiftyOne.Pipeline.Engines.FiftyOne.FlowElements.ShareUsageBase.Properties
get

Get a list of the meta-data relating to the properties that this flow element will populate.

For this share usage element, the list will always be empty as it does not populate any properties.

◆ ShareUsageUri

Uri FiftyOne.Pipeline.Engines.FiftyOne.FlowElements.ShareUsageBase.ShareUsageUri
get protected

The base URL to send usage data to.

◆ TakeTimeout

int FiftyOne.Pipeline.Engines.FiftyOne.FlowElements.ShareUsageBase.TakeTimeout
get protected

Timeout to use when taking from the queue.

◆ WriterSettings

XmlWriterSettings FiftyOne.Pipeline.Engines.FiftyOne.FlowElements.ShareUsageBase.WriterSettings
get protected
Initial value:
= new XmlWriterSettings()
{
ConformanceLevel = ConformanceLevel.Document,
Encoding = Encoding.UTF8,
CheckCharacters = true,
NewLineHandling = NewLineHandling.None,
CloseOutput = true,
}

The settings to use when creating an XML payload to send to the usage sharing web service.