Our main program
Here's our main.cs
, and you will notice that it differs from what we've seen before. The different sections are highlighted as follows:
static void Main(string[] args) { var builder = new ContainerBuilder(); // Service itself builder.RegisterType<MSBaseLogger>()?.SingleInstance(); builder.RegisterType<BitcoinMS>() .AsImplementedInterfaces() .AsSelf() ?.InstancePerLifetimeScope(); _container = builder.Build(); XmlConfigurator.ConfigureAndWatch(new FileInfo(@".log4net.config")); HostFactory.Run(c => { c?.UseAutofacContainer(_container); c?.UseLog4Net(); c?.ApplyCommandLineWithDebuggerSupport(); c?.EnablePauseAndContinue(); c?.EnableShutdown(); c?.OnException(ex => Console.WriteLine(ex.Message)); c?.Service<BitcoinMS>(s => { s.ConstructUsingAutofacContainer<BitcoinMS>(); s?.ConstructUsing(settings => { var service = AutofacHostBuilderConfigurator.LifetimeScope.Resolve<BitcoinMS>(); return service; }); s?.ConstructUsing(name => new...