public static async System.Threading.Tasks.Task Main(string[] args) { var hostbuilder = new HostBuilder() .UseWindowsService() .ConfigureAppConfiguration((hostingContext, config) => { var path = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); config .SetBasePath(path) .AddJsonFile("appsettings.json"); }) .ConfigureLogging( options => options.AddFilter <EventLogLoggerProvider>(level => level >= LogLevel.Information) ) .ConfigureServices((hostContext, services) => { //get settings from app configuration. ImporterSettings settings = hostContext.Configuration.Get <ImporterSettings>(); services .AddSingleton(settings) //add to service collection .AddHostedService <Importer>() .Configure <EventLogSettings>(config => { config.LogName = "Application"; config.SourceName = "Importer"; }); }); #if (DEBUG) await hostbuilder.RunConsoleAsync(); #else await hostbuilder.RunAsServiceAsync(); #endif }
public void AddImporterSetting(BaseImporterSetting setting) { var count = ImporterSettings.Count; for (int i = 0; i < count; i++) { if (ImporterSettings[i].Match == setting.Match) { ImporterSettings.Insert(i, setting as V); } } if (count == ImporterSettings.Count) { ImporterSettings.Add(setting as V); } }
public void RemoveImporterSetting(BaseImporterSetting setting) { ImporterSettings.Remove(setting as V); }