44 lines
1.1 KiB
Markdown
44 lines
1.1 KiB
Markdown
# Keyed Services Sample
|
|
|
|
```c#
|
|
//
|
|
// Register xMT5BridgeService ...
|
|
// services.AddXMT5BridgeService();
|
|
|
|
//
|
|
var defServiceConfig = new XServicesConfiguration();
|
|
var sServiceConfig = new XServicesConfiguration
|
|
{
|
|
Name = "SaherElm"
|
|
};
|
|
services.AddXKeyedService(sServiceConfig.Name, sServiceConfig);
|
|
services.AddXKeyedService(defServiceConfig.Name, defServiceConfig);
|
|
|
|
//
|
|
var sS = services.GetXKeyedService<XServicesConfiguration>(sServiceConfig.Name);
|
|
var defS = services.GetXKeyedService<XServicesConfiguration>(defServiceConfig.Name);
|
|
|
|
//
|
|
//
|
|
//
|
|
var dConf = new XServicesConfiguration();
|
|
var sConf = new XServicesConfiguration
|
|
{
|
|
Name = "SaherElm"
|
|
};
|
|
|
|
//
|
|
services.AddXKeyedService(
|
|
key: dConf.Name,
|
|
instance: dConf
|
|
);
|
|
services.AddXKeyedService(
|
|
key: sConf.Name,
|
|
instance: sConf
|
|
);
|
|
|
|
//
|
|
var dc = services.GetXKeyedService<XServicesConfiguration>(dConf.Name);
|
|
var sc = services.GetXKeyedService<XServicesConfiguration>(sConf.Name);
|
|
```
|