static async Task Main(string[] args) { try { var providerConfigurator = new ServiceProviderConfigurator(); var serviceProvider = await providerConfigurator.ConfigureTheWorldAsync(); using (var applicationScope = serviceProvider.CreateScope()) { var presenter = applicationScope .ServiceProvider .GetRequiredService <Presenter>(); await presenter.RunTheShowAsync(); } } catch (Exception e) { DisplayException(e); } finally { Console.WriteLine("Press Enter to continue..."); Console.ReadLine(); } }
public void Config(ServiceProviderConfigurator <IPublishSubscribeService> providerConfigurator) { var config = ConfigurationFactory.Create(); providerConfigurator.As <RabbitMqPublishSubscribeServiceProvider>(provider => provider .WithServer(config.RabbitMq.Server) .LogOnWith(config.RabbitMq.UserName, config.RabbitMq.Password)) .WithLifeStyle(LifeStyle.Singleton); }
private async Task OnExecuteAsync() { var awsOptions = new AwsOptions { AccessKey = Prompt.GetPassword("AWS Access Key", ConsoleColor.White, ConsoleColor.DarkBlue), SecretKey = Prompt.GetPassword("AWS Secret Key", ConsoleColor.White, ConsoleColor.DarkBlue) }; var queueOptions = new QueueOptions { WorkerQueueUrl = WorkerQueueUri }; var workerOptions = new WorkerOptions { Endpoint = WorkerUri }; Console.Clear(); Console.CancelKeyPress += ConsoleOnCancelKeyPress; try { using (var providerConfigurator = new ServiceProviderConfigurator()) using (var applicationScope = providerConfigurator .ConfigureTheWorld(awsOptions, queueOptions, workerOptions).CreateScope()) { var messagePump = applicationScope .ServiceProvider .GetRequiredService <MessagePump>(); await messagePump.RunAsync(Token); } } catch (Exception e) { Console.WriteLine("Exception: {0}", e.GetType()); Console.WriteLine("Message: {0}", e.Message); Console.WriteLine("StackTrace:"); Console.WriteLine(e.Demystify().StackTrace); } finally { Console.WriteLine("Press Enter to continue..."); Console.ReadLine(); } }