Pip-Services-Commons-Dotnet
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
PipServices3.Commons.Refer.References Class Reference

The most basic implementation of IReferences to store and locate component references. More...

Inheritance diagram for PipServices3.Commons.Refer.References:
PipServices3.Commons.Refer.IReferences

Public Member Functions

 References (object[] tuples)
 Creates a new instance of references and initializes it with references. More...
 
virtual void Put (object locator, object component)
 Puts a new reference into this reference map. More...
 
virtual object Remove (object locator)
 Removes a previously added reference that matches specified locator. If many references match the locator, it removes only the first one.When all references shall be removed, use removeAll() method instead. More...
 
virtual List< object > RemoveAll (object locator)
 Removes all component references that match the specified locator. More...
 
virtual List< object > GetAllLocators ()
 Gets locators for all registered component references in this reference map. More...
 
virtual List< object > GetAll ()
 Gets all component references registered in this reference map. More...
 
virtual object GetOneOptional (object locator)
 Gets an optional component reference that matches specified locator. More...
 
virtual T GetOneOptional< T > (object locator)
 Gets an optional component reference that matches specified locator and matching to the specified type. More...
 
virtual object GetOneRequired (object locator)
 Gets a required component reference that matches specified locator. More...
 
virtual T GetOneRequired< T > (object locator)
 Gets a required component reference that matches specified locator and matching to the specified type. More...
 
virtual List< object > GetOptional (object locator)
 Gets all component references that match specified locator. More...
 
virtual List< T > GetOptional< T > (object locator)
 Gets all component references that match specified locator and matching to the specified type. More...
 
virtual List< object > GetRequired (object locator)
 Gets all component references that match specified locator. At least one component reference must be present. More...
 
virtual List< T > GetRequired< T > (object locator)
 Gets all component references that match specified locator. At least one component reference must be present and matching to the specified type. More...
 
virtual List< object > Find (object locator, bool required)
 Gets all component references that match specified locator. More...
 
virtual List< T > Find< T > (object locator, bool required)
 Gets all component references that match specified locator and matching to the specified type. More...
 
void Clear ()
 Clears this instance. More...
 

Static Public Member Functions

static References FromTuples (params object[] tuples)
 

Protected Attributes

readonly List< Reference_references = new List<Reference>()
 
readonly object _lock = new object()
 

Detailed Description

The most basic implementation of IReferences to store and locate component references.

public class MyController: IReferenceable
{
public IMyPersistence _persistence;
...
public void SetReferences(IReferences references)
{
this._persistence = references.getOneRequired<IMyPersistence>(
new Descriptor("mygroup", "persistence", "*", "*", "1.0") );
}
...
}
var persistence = new MyMongoDbPersistence();
var controller = new MyController();
var references = References.FromTuples(
new Descriptor("mygroup", "persistence", "mongodb", "default", "1.0"), persistence,
new Descriptor("mygroup", "controller", "default", "default", "1.0"), controller);
controller.SetReferences(references);

See IReferences

Constructor & Destructor Documentation

◆ References()

PipServices3.Commons.Refer.References.References ( object []  tuples)

Creates a new instance of references and initializes it with references.

Parameters
tuples(optional) a list of values where odd elements are locators and the following even elements are component references

Member Function Documentation

◆ Clear()

void PipServices3.Commons.Refer.References.Clear ( )

Clears this instance.

◆ Find()

virtual List<object> PipServices3.Commons.Refer.References.Find ( object  locator,
bool  required 
)
virtual

Gets all component references that match specified locator.

Parameters
locatorthe locator to find a reference by.
requiredforces to raise exception is no reference is found
Returns
a list with matching component references.

Implements PipServices3.Commons.Refer.IReferences.

◆ Find< T >()

virtual List<T> PipServices3.Commons.Refer.References.Find< T > ( object  locator,
bool  required 
)
virtual

Gets all component references that match specified locator and matching to the specified type.

Template Parameters
Tthe class type
Parameters
locatorthe locator to find a reference by.
requiredforces to raise exception is no reference is found
Returns
a list with matching component references.

Implements PipServices3.Commons.Refer.IReferences.

◆ GetAll()

virtual List<object> PipServices3.Commons.Refer.References.GetAll ( )
virtual

Gets all component references registered in this reference map.

Returns
a list with component references.

Implements PipServices3.Commons.Refer.IReferences.

◆ GetAllLocators()

virtual List<object> PipServices3.Commons.Refer.References.GetAllLocators ( )
virtual

Gets locators for all registered component references in this reference map.

Returns
a list with component locators.

Implements PipServices3.Commons.Refer.IReferences.

◆ GetOneOptional()

virtual object PipServices3.Commons.Refer.References.GetOneOptional ( object  locator)
virtual

Gets an optional component reference that matches specified locator.

Parameters
locatora locator to find a reference
Returns
a found component reference or
null
if nothing was found

Implements PipServices3.Commons.Refer.IReferences.

◆ GetOneOptional< T >()

virtual T PipServices3.Commons.Refer.References.GetOneOptional< T > ( object  locator)
virtual

Gets an optional component reference that matches specified locator and matching to the specified type.

Template Parameters
Tthe class type
Parameters
locatora locator to find a reference
Returns
a found component reference or
null
if nothing was found

Implements PipServices3.Commons.Refer.IReferences.

◆ GetOneRequired()

virtual object PipServices3.Commons.Refer.References.GetOneRequired ( object  locator)
virtual

Gets a required component reference that matches specified locator.

Parameters
locatora locator to find a reference
Returns
a matching component reference.

Implements PipServices3.Commons.Refer.IReferences.

◆ GetOneRequired< T >()

virtual T PipServices3.Commons.Refer.References.GetOneRequired< T > ( object  locator)
virtual

Gets a required component reference that matches specified locator and matching to the specified type.

Template Parameters
Tthe class type
Parameters
locatora locator to find a reference
Returns
a found component reference

Implements PipServices3.Commons.Refer.IReferences.

◆ GetOptional()

virtual List<object> PipServices3.Commons.Refer.References.GetOptional ( object  locator)
virtual

Gets all component references that match specified locator.

Parameters
locatora locator to find references by
Returns
a list with matching component references or empty list if nothing was found.

Implements PipServices3.Commons.Refer.IReferences.

◆ GetOptional< T >()

virtual List<T> PipServices3.Commons.Refer.References.GetOptional< T > ( object  locator)
virtual

Gets all component references that match specified locator and matching to the specified type.

Template Parameters
Tthe class type
Parameters
locatorthe locator to find references by.
Returns
a list with matching component references or empty list if nothing was found.

Implements PipServices3.Commons.Refer.IReferences.

◆ GetRequired()

virtual List<object> PipServices3.Commons.Refer.References.GetRequired ( object  locator)
virtual

Gets all component references that match specified locator. At least one component reference must be present.

Parameters
locatora locator to find references
Returns
a list with found component references

Implements PipServices3.Commons.Refer.IReferences.

◆ GetRequired< T >()

virtual List<T> PipServices3.Commons.Refer.References.GetRequired< T > ( object  locator)
virtual

Gets all component references that match specified locator. At least one component reference must be present and matching to the specified type.

Template Parameters
Tthe class type
Parameters
locatora locator to find references
Returns
a list with found component references

Implements PipServices3.Commons.Refer.IReferences.

◆ Put()

virtual void PipServices3.Commons.Refer.References.Put ( object  locator,
object  component 
)
virtual

Puts a new reference into this reference map.

Parameters
locatora locator to find the reference by.
componenta component reference to be added.

Implements PipServices3.Commons.Refer.IReferences.

◆ Remove()

virtual object PipServices3.Commons.Refer.References.Remove ( object  locator)
virtual

Removes a previously added reference that matches specified locator. If many references match the locator, it removes only the first one.When all references shall be removed, use removeAll() method instead.

Parameters
locatora locator to remove reference
Returns
the removed component reference.

See RemoveAll(object)

Implements PipServices3.Commons.Refer.IReferences.

◆ RemoveAll()

virtual List<object> PipServices3.Commons.Refer.References.RemoveAll ( object  locator)
virtual

Removes all component references that match the specified locator.

Parameters
locatorthe locator to remove references by.
Returns
a list, containing all removed references.

Implements PipServices3.Commons.Refer.IReferences.


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