amielc1 / LearnDDS

Practice DDS Communication by use openddsharp .net library
1 stars 0 forks source link

Implement Dependency Injection #4

Open amielc1 opened 3 months ago

amielc1 commented 3 months ago

Add Extention method for IServiceCollection (in the project we write how to add our class into the IOC container, in the runner project -> program.cs we invoke this extention method )

for example :


>    public static void AddMessageBrokerProducerServicesRabbitMq(this IServiceCollection services,
>         RabbitMqConfiguration rabbitMqConfiguration)
>     {
>         services.AddSingleton<IPublisher, Publisher>();
>         services.AddSingleton(_ => new RabbitMqBuilderAdapter(rabbitMqConfiguration));
>         services.AddSingleton<IProducerAdapter, RabbitMqProducerAdapter>();
>     }