private void SetUpGraphQL(IServiceCollection services) { // setup taken from https://github.com/GraphQL-dotnet/examples/blob/master/src/AspNetCore/Example/Startup.cs#L15 services.AddTransient(sc => { var validatorTypeCache = new ValidatorTypeCache(true); validatorTypeCache.AddValidatorsFromAssembly(typeof(Startup).Assembly); return(validatorTypeCache); }); services.AddSingleton <IDocumentExecuter, DocumentExecuter>(); services.AddSingleton <IDocumentWriter, DocumentWriter>(); services.AddSingleton <PropertiesQuery>(); services.AddSingleton <PropertiesMutation>(); services.AddSingleton <CreateOrUpdatePropertyNoteInputType>(); services.AddSingleton <PriceChangeType>(); services.AddSingleton <PropertyType>(); services.AddSingleton <ISchema, Schema>(); services.AddSingleton <CreateOrUpdatePropertyNoteInputValidator>(); }
static ValidatorCacheBuilder() { Instance = new(useDependencyInjection : false); Instance.AddValidatorsFromAssembly(typeof(Startup).Assembly); InstanceDI = new(useDependencyInjection : true); InstanceDI.AddValidatorsFromAssembly(typeof(Startup).Assembly); }
void ExecuteQuery(Assembly assemblyContainingValidators) { #region StartConfig var validatorTypeCache = new ValidatorTypeCache(); validatorTypeCache.AddValidatorsFromAssembly(assemblyContainingValidators); var schema = new Schema(); var executer = new DocumentExecuter(); #endregion }
static ValidatorCacheBuilder() { Instance = new ValidatorTypeCache(); Instance.AddValidatorsFromAssembly(typeof(Startup).Assembly); }