Class ServiceContainer
Inheritance
ServiceContainer
Implements
IServiceCollection
Assembly: Neon.Common.dll
Syntax
public class ServiceContainer : IServiceContainer, IServiceCollection
Constructors
ServiceContainer()
Declaration
public ServiceContainer()
Properties
Count
Declaration
public int Count { get; }
Property Value
IsReadOnly
Declaration
public bool IsReadOnly { get; }
Property Value
this[int]
Declaration
public ServiceDescriptor this[int index] { get; set; }
Parameters
| Type |
Name |
Description |
| int |
index |
|
Property Value
| Type |
Description |
| ServiceDescriptor |
|
Methods
Add(ServiceDescriptor)
Declaration
public void Add(ServiceDescriptor item)
Parameters
| Type |
Name |
Description |
| ServiceDescriptor |
item |
|
Clear()
Declaration
Clone()
Returns a clone of the instance. This can be useful for unit testing to save
the service container before executing a test and then restoring it afterwards.
Declaration
public ServiceContainer Clone()
Returns
Contains(ServiceDescriptor)
Declaration
public bool Contains(ServiceDescriptor item)
Parameters
| Type |
Name |
Description |
| ServiceDescriptor |
item |
|
Returns
CopyTo(ServiceDescriptor[], int)
Declaration
public void CopyTo(ServiceDescriptor[] array, int arrayIndex)
Parameters
| Type |
Name |
Description |
| ServiceDescriptor[] |
array |
|
| int |
arrayIndex |
|
GetEnumerator()
Declaration
public IEnumerator<ServiceDescriptor> GetEnumerator()
Returns
GetService(Type)
Gets the service object of the specified type.
Declaration
public object GetService(Type serviceType)
Parameters
| Type |
Name |
Description |
| Type |
serviceType |
An object that specifies the type of service object to get.
|
Returns
| Type |
Description |
| object |
A service object of type serviceType.
-or-
null if there is no service object of type serviceType.
|
GetService<TService>()
This is a convenience generic method that returns the service
already cast to requested type.
Declaration
public TService GetService<TService>()
Returns
| Type |
Description |
| TService |
The service instance if it exists or null.
|
Type Parameters
| Name |
Description |
| TService |
Specifies the desired service type.
|
IndexOf(ServiceDescriptor)
Declaration
public int IndexOf(ServiceDescriptor item)
Parameters
| Type |
Name |
Description |
| ServiceDescriptor |
item |
|
Returns
Insert(int, ServiceDescriptor)
Declaration
public void Insert(int index, ServiceDescriptor item)
Parameters
| Type |
Name |
Description |
| int |
index |
|
| ServiceDescriptor |
item |
|
Remove(ServiceDescriptor)
Declaration
public bool Remove(ServiceDescriptor item)
Parameters
| Type |
Name |
Description |
| ServiceDescriptor |
item |
|
Returns
RemoveAt(int)
Declaration
public void RemoveAt(int index)
Parameters
| Type |
Name |
Description |
| int |
index |
|
Implements
IServiceCollection