This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Assembly ConsoleAppAssembly = typeof(Program).Assembly; | |
| var ConsoleAppTypes = | |
| from type in ConsoleAppAssembly.GetTypes() | |
| where !type.IsAbstract | |
| where typeof(ICustomer).IsAssignableFrom(type) | |
| select type; | |
| foreach (var type in ConsoleAppTypes) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Injector.Abstractions; | |
| using System; | |
| using System.Collections.Generic; | |
| using System.Text; | |
| namespace Injector | |
| { | |
| class ConsoleApplication | |
| { | |
| private readonly ICustomer _customer; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static void Main(string[] args) | |
| { | |
| RegisterServices(); | |
| IServiceScope scope = _serviceProvider.CreateScope(); | |
| scope.ServiceProvider.GetRequiredService<ConsoleApplication>().Run(); | |
| DisposeServices(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static void DisposeServices() | |
| { | |
| if (_serviceProvider == null) | |
| { | |
| return; | |
| } | |
| if (_serviceProvider is IDisposable) | |
| { | |
| ((IDisposable)_serviceProvider).Dispose(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static void RegisterServices() | |
| { | |
| var services = new ServiceCollection(); | |
| services.AddSingleton<ICustomer, Customer>(); | |
| services.AddSingleton<ConsoleApplication>(); | |
| _serviceProvider = services.BuildServiceProvider(true); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var section = Configuration.GetSection("Sectionofsettings"); | |
| var section = Configuration.GetValue("Onesetting"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static async Task Main(string[] args) | |
| { | |
| IConfiguration Configuration = new ConfigurationBuilder() | |
| .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) | |
| .AddEnvironmentVariables() | |
| .AddCommandLine(args) | |
| .Build(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Install-Package Microsoft.Extensions.Configuration | |
| Install-Package Microsoft.Extensions.Configuration.Json | |
| Install-Package Microsoft.Extensions.Configuration.CommandLine | |
| Install-Package Microsoft.Extensions.Configuration.EnvironmentVariables |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static IWebHostBuilder CreateWebHostBuilder(string[] args) | |
| { | |
| return WebHost.CreateDefaultBuilder(args) | |
| .ConfigureKestrel(options => | |
| { | |
| options.Listen(IPAddress.Any, 8080, listenOptions => | |
| { | |
| listenOptions.Protocols = HttpProtocols.Http1AndHttp2; | |
| listenOptions.UseHttps("testcertificate.pfx", "donotusepassword"); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Resources: | |
| SQSQueue: | |
| Type: AWS::SQS::Queue | |
| Properties: | |
| QueueName: my-sqsqueue | |
| Output: | |
| SQSQueueURL: | |
| Value: !Ref SQSQueue | |
| Export: |