C# | Visual Basic | Visual C++ |
public interface INamespace
Public Interface INamespace
public interface class INamespace
All Members | Methods | ||||
Icon | Member | Description |
---|---|---|
Match(String) |
Tests an String to see if it falls within this INamespace.
|
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 IPublisher and to ensure that the associated IDataProvider only receives requests for subjects that it can supply.
DataSource.NET includes the following implementations of INameSpace:
- PrefixNamespace, which matches the start of a subject name.
- RegexNamespace, for more complex subject matching requirements.
In particular, the 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
using Caplin.DataSource; using Caplin.DataSource.Namespace; 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 } }