DataSource.NET  7.1.32.168791-9652659d
Caplin.DataSource.Namespace.INamespace Interface Reference

An INamespace is used to determine if a subject is of interest to an Caplin.DataSource.Publisher.IDataProvider. More...

Inheritance diagram for Caplin.DataSource.Namespace.INamespace:
Caplin.DataSource.Namespace.PrefixNamespace Caplin.DataSource.Namespace.RegexNamespace

Public Member Functions

bool Match (string subject)
 Tests an string to see if it falls within this INamespace. More...
 

Detailed Description

An INamespace is used to determine if a subject is of interest to an Caplin.DataSource.Publisher.IDataProvider.

A subject name is defined within a DataSource namespace. For example, if the DataSource namespace is the prefix "/FX" the subject name "/FX/EURUSD" is within that namespace, but "/FY/EURUSD" is not. INamespace is the interface that represents a DataSource namespace.

An INamespace is used to construct an Caplin.DataSource.Publisher.IPublisher and to ensure that the associated Caplin.DataSource.Publisher.IDataProvider only receives requests for subjects that it can supply.

DataSource.NET includes the following implementations of INameSpace:

In particular, the Caplin.DataSource.Namespace.RegexNamespace provides a flexible way to match subjects against inclusion and exclusion patterns, so you should not normally need to use INamespace directly. However, should the supplied DataSource namespace implementations not match your requirements you can write your own custom subject matching logic in an implementation of INamespace.

The following example provides a simple prefix matching INamespace implementation

namespace DataSourceExamples.Namespace
{
class PrefixNamespaceExample : INamespace
{
string prefix;
public PrefixNamespaceExample(string prefix)
{
this.prefix = prefix;
}
#region INamespace Members
public bool Match(string subject)
{
return subject.ToString().StartsWith(prefix);
}
#endregion
}
}

Member Function Documentation

bool Caplin.DataSource.Namespace.INamespace.Match ( string  subject)

Tests an string to see if it falls within this INamespace.

Parameters
subjectThe string to be tested for matching
Returns
True if subject falls within this INamespace, false otherwise

An example of a simple prefix based INamespace implementation is below. Note the ToString() method is used to to obtain the full string-version of the string.

namespace DataSourceExamples.Namespace
{
class PrefixNamespaceExample : INamespace
{
string prefix;
public PrefixNamespaceExample(string prefix)
{
this.prefix = prefix;
}
#region INamespace Members
public bool Match(string subject)
{
return subject.ToString().StartsWith(prefix);
}
#endregion
}
}

Implemented in Caplin.DataSource.Namespace.RegexNamespace, and Caplin.DataSource.Namespace.PrefixNamespace.


Generated on Wed Oct 18 2023 17:20:25 for DataSource.NET