public object TryResolve(Type type) { object instance; return(RootResolver.TryResolve(type, out instance) ? instance : null); }
public CrudModuleQueries( RootResolver <Contact> contactResolver, RootResolver <Species> speciesResolver, RootResolver <Breed> breedResolver, RootResolver <Location> locationResolver ) { this._contactResolver = contactResolver; this._speciesResolver = speciesResolver; this._breedResolver = breedResolver; this._locationResolver = locationResolver; }
public void AddGenericMutationAsync <TMutation, TResolverSource>( string name, RootResolver <TResolverSource> resolver ) where TMutation : GraphType where TResolverSource : class { this.FieldAsync <TMutation>( name, arguments: resolver, resolve: ctx => resolver.ResolveAsync(ctx, base.DataContext) ); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IApplicationLifetime applicationLifetime) { loggerFactory.AddNLog(); app.AddNLogWeb(); app.UseMvc(); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Stove WebApi Core"); }); applicationLifetime.ApplicationStopped.Register(() => { RootScope.Dispose(); RootResolver.Dispose(); }); }
public void DefineSingleAndConnection <TGraphType, TSourceType>(string name, RootResolver <TSourceType> resolver) where TGraphType : GraphType where TSourceType : class { var namePlural = (name.EndsWith("s")) ? name + "es" // species -> specieses. Since we *have* to differentiate, even if not gramatically correct. : name + "s"; // contact -> contacts. this.FieldAsync <TGraphType>( name, arguments: resolver, resolve: ctx => resolver.ResolveAsync(ctx, base.DataContext) ); this.DefineConnectionAsync <object, TGraphType, TSourceType>( namePlural, base.DataContext, (ctx, first, after, order) => resolver.ResolvePageAsync(ctx, first, after, order) ); }
public object Resolve(Type type) { return(RootResolver.Resolve(type)); }
public T Resolve <T>() { return(RootResolver.Resolve <T>()); }
public AccountQueries(RootResolver <DataAccessUserContext> resolver) { this._resolver = resolver; }
// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddAutofac(); // Add framework services. services.AddMvc().AddControllersAsServices(); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "Stove Web Api", Version = "v1" }); }); IocBuilder builder = IocBuilder.New; RootResolver = builder.UseStove <StoveWebApiCoreBootstrapper>() .UseStoveEntityFrameworkCore(configuration => configuration) .AddStoveDbContext <AnimalDbContext>(contextConfiguration => { if (contextConfiguration.ExistingConnection != null) { contextConfiguration.DbContextOptions.UseSqlServer(contextConfiguration.ExistingConnection); } else { contextConfiguration.DbContextOptions.UseSqlServer(Configuration.GetConnectionString("Default")); } }) .AddStoveDbContext <PersonDbContext>(contextConfiguration => { if (contextConfiguration.ExistingConnection != null) { contextConfiguration.DbContextOptions.UseSqlServer(contextConfiguration.ExistingConnection); } else { contextConfiguration.DbContextOptions.UseSqlServer(Configuration.GetConnectionString("Default")); } }) .UseStoveDapper() .UseStoveTypedConnectionStringResolver() .UseStoveEventBus() .UseStoveBackgroundJobs() .UseStoveMapster() .UseStoveHangfire(configuration => { configuration.GlobalConfiguration .UseSqlServerStorage(Configuration.GetConnectionString("Default")) .UseNLogLogProvider(); return(configuration); }) .UseStoveNLog() .UseStoveRabbitMQ(configuration => { configuration.HostAddress = "rabbitmq://localhost/"; configuration.Username = "******"; configuration.Password = "******"; configuration.QueueName = "NetCore2"; return(configuration); }) .UseStoveRedisCaching(configuration => { configuration.ConfigurationOptions .AddEndpoint("127.0.0.1") .SetDefaultDatabase(0) .SetConnectionTimeOut(TimeSpan.FromMinutes(5)); return(configuration); }) .RegisterServices(r => { r.RegisterAssemblyByConvention(typeof(Startup).GetAssembly()); r.BeforeRegistrationCompleted += (sender, args) => { args.ContainerBuilder.Populate(services); }; }) .CreateResolver(); RootResolver.Resolve <ILogger>().Error("anan"); return(new AutofacServiceProvider(RootResolver.Container)); }