// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc(); // Resolver dependencias no momento em que a api é chamada DependencyResolve.RegisterServices(services); // Configuração do swagger para testar a API services.AddSwaggerGen(x => { x.SwaggerDoc("v1", new Info { Title = "SchoolOccurrences", Version = "v1" }); // x.AddSecurityDefinition("Bearer", new ApiKeyScheme() { In = "header", Description = "Bearer Token", Name = "Authorization", Type = "apiKey" }); }); services.Configure <MvcOptions>(options => { options.Filters.Add(new CorsAuthorizationFilterFactory("AllowSpecificOrigin")); }); services.AddCors(options => { options.AddPolicy("AllowSpecificOrigin", builder => builder.WithOrigins("http://localhost:4200").AllowAnyHeader() .AllowAnyMethod()); }); }
static async Task Main(string[] args) { ServiceProvider serviceProvider = DependencyResolve.Resolve(); IElasticWriterRepository _cacheService = serviceProvider.GetService <IElasticWriterRepository>(); await VerifyConnectionElastic(_cacheService); Console.WriteLine("Carga Iniciada!"); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); var zipPath = $"{AppDomain.CurrentDomain.BaseDirectory}{Path.DirectorySeparatorChar}sample_data{Path.DirectorySeparatorChar}"; var zipName = "CollegeScorecard_Raw_Data.zip"; var seeder = ScoreCardSeed.Create(zipPath, zipName, _cacheService); await seeder.Seed(); stopwatch.Stop(); Console.WriteLine($"Tempo total da carga: { stopwatch.ElapsedMilliseconds / 1000 } segundos."); Console.WriteLine("Carga Finalizada!"); }
static void Main(string[] args) { ServiceProvider serviceProvider = DependencyResolve.Resolve(); ICacheService _cacheService = serviceProvider.GetService <ICacheService>(); const string exitCode = "exit"; var watch = new Stopwatch(); while (true) { Console.WriteLine($"Type any key to save/read to the redis cache or {exitCode} to exit: "); string inputText = Console.ReadLine(); if (inputText.Trim() == string.Empty) { continue; } else if (inputText.Trim() == exitCode) { break; } watch.Start(); var reponse = _cacheService .GetOrSet <ItemKey>(inputText, () => { return(ItemKey.Create(inputText)); //Can be your database read }); watch.Stop(); Console.WriteLine(reponse); Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss")} - Runtime {watch.ElapsedMilliseconds} milliseconds"); } }
public ClaimApiController() { _iClaimReverseHelper = DependencyResolve.GetClaimReverseInstance(); }