public InfoFileLoggerProvider( FileLoggerContext context, IOptionsMonitor <FileLoggerOptions> options, string optionsName ) : base(context, options, optionsName) { }
private static IServiceProvider BuilderDi() { var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json"); var configuration = builder.Build(); var appSettings = new AppSettings(); configuration.GetSection("app").Bind(appSettings); var services = new ServiceCollection(); var context = new FileLoggerContext(AppContext.BaseDirectory, "coin.log"); services.AddSingleton(new LoggerFactory().AddFile(context, configuration)); services.AddLogging(); services.AddSingleton(configuration); services.AddSingleton(appSettings); services.AddDbContext <CoinContext>(options => { options.UseSqlite("Data Source=cointrader.db"); //options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")); }, ServiceLifetime.Transient); services.AddMemoryCache(); services.AddSingleton <ISelfInspectionService, SelfInspectionService>(); services.AddSingleton <IOrderService, OrderService>(); services.AddSingleton <IBitstampConfig, BitstampConfig>(); services.AddSingleton <IGdaxConfig, GdaxConfig>(); services.AddSingleton <IBitstampCurrencyMapper, BitstampCurrencyMapper>(); services.AddSingleton <IGdaxCurrencyMapper, GdaxCurrencyMapper>(); services.AddSingleton <IGdaxOrderStatusMapper, GdaxOrderStatusMapper>(); services.AddSingleton <IBitmapOrderStatusMapper, BitstampOrderStatusMapper>(); services.AddSingleton <IBitstampDataClient, BitstampDataClient>(); services.AddSingleton <IGdaxDataClient, GdaxDataClient>(); if (appSettings.Production) { services.AddSingleton <IBitstampTradeClient, BitstampTradeClient>(); services.AddSingleton <IGdaxTradeClient, GdaxTradeClient>(); } else { services.AddSingleton <IBitstampTradeClient, BitstampFakeTradeClient>(); services.AddSingleton <IGdaxTradeClient, GdaxFakeTradeClient>(); } services.AddSingleton <IObservationService, ObservationFileService>(); services.AddSingleton <IExchangeDataService, ExchangeDataService>(); services.AddSingleton <IExchangeTradeService, ExchangeTradeService>(); services.AddSingleton <IMessageService, ConsoleMessageService>(); services.AddSingleton <IOpportunityService, OpportunityService>(); services.AddSingleton <IArbitrageService, ArbitrageService>(); services.AddSingleton <IWorker, Worker>(); services.AddOptions(); services.AddTransient <App>(); var serviceProvider = services.BuildServiceProvider(); return(serviceProvider); }
public static ILoggingBuilder AddFile(this ILoggingBuilder builder, FileLoggerContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } return(builder.AddFile(Options.Options.DefaultName, sp => new FileLoggerProvider(context, sp.GetRequiredService <IOptionsMonitor <FileLoggerOptions> >()))); }
public static ILoggingBuilder AddFile(this ILoggingBuilder builder, FileLoggerContext context, Action <FileLoggerOptions> configure) { if (configure == null) { throw new ArgumentNullException(nameof(configure)); } builder.AddFile(context); builder.Services.Configure(configure); return(builder); }
public CustomFileLoggerProcessor(FileLoggerContext context) : base(context) { }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var appSettings = new AppSettings(); Configuration.GetSection("app").Bind(appSettings); var context = new FileLoggerContext(AppContext.BaseDirectory, "coin.log"); services.AddSingleton(new LoggerFactory().AddFile(context, Configuration)); services.AddLogging(); services.AddSingleton(Configuration); services.AddSingleton(appSettings); services.AddDbContext <CoinContext>(options => { options.UseSqlite("Data Source=cointrader.db"); //options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")); }, ServiceLifetime.Scoped); services.AddMemoryCache(); services.AddScoped <ICoinContextService, CoinContextService>(); services.AddScoped <ISelfInspectionService, SelfInspectionService>(); services.AddScoped <IOrderService, OrderService>(); services.AddScoped <IBitstampConfig, BitstampConfig>(); services.AddScoped <IGdaxConfig, GdaxConfig>(); services.AddScoped <IBl3pConfig, Bl3pConfig>(); services.AddScoped <IBitstampCurrencyMapper, BitstampCurrencyMapper>(); services.AddScoped <IGdaxCurrencyMapper, GdaxCurrencyMapper>(); services.AddScoped <IBl3pCurrencyMapper, Bl3pCurrencyMapper>(); services.AddScoped <IGdaxOrderStatusMapper, GdaxOrderStatusMapper>(); services.AddScoped <IBitmapOrderStatusMapper, BitstampOrderStatusMapper>(); services.AddSingleton <IBitstampDataClient, BitstampDataClient>(); services.AddSingleton <IGdaxDataClient, GdaxDataClient>(); services.AddSingleton <IBl3pDataClient, Bl3pDataClient>(); if (appSettings.Production) { services.AddSingleton <IBitstampTradeClient, BitstampTradeClient>(); services.AddSingleton <IGdaxTradeClient, GdaxTradeClient>(); services.AddSingleton <IBl3pTradeClient, Bl3pTradeClient>(); } else { services.AddSingleton <IBitstampTradeClient, BitstampFakeTradeClient>(); services.AddSingleton <IGdaxTradeClient, GdaxFakeTradeClient>(); services.AddSingleton <IBl3pTradeClient, Bl3pFakeTradeClient>(); } services.AddScoped <IObservationService, ObservationService>(); services.AddScoped <IExchangeDataService, ExchangeDataService>(); services.AddScoped <IExchangeTradeService, ExchangeTradeService>(); services.AddScoped <IMessageService, MessageService>(); services.AddScoped <IOpportunityService, OpportunityService>(); services.AddScoped <IArbitrageService, ArbitrageService>(); services.AddScoped <IExchangeSetting, ExchangeSetting>(); services.AddScoped <IExchangeConfigService, ExchangeConfigService>(); services.AddScoped <IWorker, Worker>(); services.AddScoped <App, App>(); services.AddOptions(); // Add framework services. services.AddMvc(); }
public static ILoggingBuilder AddFile <TProvider>(this ILoggingBuilder builder, FileLoggerContext context = null, Action <FileLoggerOptions> configure = null, string optionsName = null) where TProvider : FileLoggerProvider { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (optionsName == null) { optionsName = typeof(TProvider).ToString(); } if (context == null) { context = FileLoggerContext.Default; } builder.AddFile(optionsName, sp => ActivatorUtilities.CreateInstance <TProvider>(sp, context, optionsName)); if (configure != null) { builder.Services.Configure(optionsName, configure); } return(builder); }