public JumpCache(IServiceProvider services) { _api = (EVEStandardAPI)services.GetService(typeof(EVEStandardAPI)); _tranquilityDbContext = (TranquilityContext)services.GetService(typeof(TranquilityContext)); _navigatorDbContext = (NavigatorContext)services.GetService(typeof(NavigatorContext)); _solarSystemRepository = new SolarSystemRepository(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); // Add cookie authentication and set the login url services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(options => { options.LoginPath = "/Auth/Login"; }); if (File.Exists(SecretsFileName) == false) { throw new InvalidOperationException("You need to have a secrets file setup"); } var secrets = JsonConvert.DeserializeObject <Secrets>(File.ReadAllText(SecretsFileName)); // Register your application at: https://developers.eveonline.com/applications to obtain client ID and secret key and add them to user secrets // by right-clicking the solution and selecting Manage User Secrets. // Also, modify the callback URL in appsettings.json to match with your environment. // Initialize the client var esiClient = new EVEStandardAPI( "EVEAsset.Navigator", // User agent DataSource.Tranquility, // Server [Tranquility/Singularity] TimeSpan.FromSeconds(30), // Timeout Configuration["SSOCallbackUrl"], secrets.ClientId, secrets.SecretKey); // Register with DI container services.AddSingleton(esiClient); // Session is required services.AddSession(); services.AddMemoryCache(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); var tranquilityContext = new TranquilityContext(new DbContextOptions <TranquilityContext>()); tranquilityContext.ConfigureServices(services, secrets.SdeConnectionString); var navigatorContext = new NavigatorContext(new DbContextOptions <NavigatorContext>()); navigatorContext.ConfigureServices(services, secrets.NavigatorConnectionString); services.AddSingleton(typeof(TranquilityContext), tranquilityContext); services.AddSingleton(typeof(NavigatorContext), navigatorContext); services.AddSingleton <IUniverseCache, UniverseCache>(); services.AddSingleton <IStaticDataRepository, StaticDataRepository>(); services.AddSingleton <IJumpCache, JumpCache>(); }
public UniverseCache(IServiceProvider services) { _cache = services.GetService <IMemoryCache>(); _api = (EVEStandardAPI)services.GetService(typeof(EVEStandardAPI)); _dbContext = (TranquilityContext)services.GetService(typeof(TranquilityContext)); if (!_cache.TryGetValue(MemoryCacheKeys.UniverseMapping, out List <UniverseIdsToNames> _universeMapping)) { _universeMapping = new List <UniverseIdsToNames>(); _cache.Set(MemoryCacheKeys.UniverseMapping, _universeMapping, new MemoryCacheEntryOptions { Priority = CacheItemPriority.NeverRemove }); //Prepopulate the in memory cache with all the known solar systems _universeMapping.AddRange(GetSolarSystems()); } }
public StaticDataRepository(IServiceProvider provider) { _dbContext = (TranquilityContext)provider.GetService(typeof(TranquilityContext)); _solarSystemRepository = new SolarSystemRepository(); }
public LoyaltyController(IServiceProvider provider) { _api = (EVEStandardAPI)provider.GetService(typeof(EVEStandardAPI)); _tranquilityDbContext = (TranquilityContext)provider.GetService(typeof(TranquilityContext)); }