Created
April 16, 2022 12:12
-
-
Save obegendi/9537f11106554914d2bcee0077770322 to your computer and use it in GitHub Desktop.
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 class Program{ | |
static void Main() | |
{ | |
var configurationRoot = new ConfigurationBuilder() | |
.SetBasePath(Directory.GetCurrentDirectory()) | |
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: false) | |
.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json", optional: true) | |
.Build(); | |
Log.Logger = new LoggerConfiguration() | |
.WriteTo.Debug() | |
.WriteTo.File("./logs/log.txt", rollingInterval: RollingInterval.Day) | |
.MinimumLevel.Warning() | |
.CreateLogger(); | |
Start.Init(configurationRoot); | |
var formFactory = CompositionRoot(); | |
ApplicationConfiguration.Initialize(); | |
Application.Run(formFactory.CreateMain()); | |
} | |
static IHostBuilder CreateHostBuilder() | |
{ | |
return Host.CreateDefaultBuilder() | |
.ConfigureServices((context, services) => | |
{ | |
services.Configure<AppSettings>(context.Configuration); | |
services.AddOptions<AppSettings>(); | |
//servicesler burada eklenecek | |
}); | |
} | |
} | |
public class SampleJobService : IJobCommand{ | |
AppSettings _settings; | |
public Configuration(IOptions<AppSettings> options) | |
{ | |
_appsettings = options.Value; | |
} | |
public int JobId { get; set; } | |
public void Execute(){ | |
// Make awesome stuff | |
var ep = _appsettings.AmazanEndpoint; | |
//Request to this ep.ü | |
// etc | |
// etc | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment