Our program
Here is a look at our Main
function, completely filled out. We register our types and interfaces, build the Autofac
container, and configure and then run the microservice. We also configured the microservice with leadership ability as seen in earlier chapters, in case you decide to run multiple instances of the microservice. Wow, that would be chatty, wouldn't it?:
static void Main(string[] args) { var builder = new ContainerBuilder(); // Service itself builder.RegisterType<MSBaseLogger>()?.SingleInstance(); builder.RegisterType<SpeechBot>() .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?.UseWindowsHostEnvironmentWithDebugSupport...