public void OnApplicationStartup( IServiceCollection services, ServiceProvider serviceProvider, IConfigurationProvider config) { var loggerFactory = serviceProvider.GetService <ILoggerFactory>(); var model = new BocModel(); var sessionFactory = new SessionFactory( config, model, loggerFactory.CreateLogger <SessionFactory>()); var qp = new QueryParser(sessionFactory, model, loggerFactory.CreateLogger <QueryParser>()); var httpParser = new HttpQueryParser(qp); services.AddSingleton(typeof(IStringModel), model); services.AddSingleton(typeof(ISessionFactory), sessionFactory); services.AddSingleton(typeof(SessionFactory), sessionFactory); services.AddSingleton(typeof(QueryParser), qp); services.AddSingleton(typeof(HttpQueryParser), httpParser); services.AddSingleton(typeof(IHttpWriter), new HttpWriter(sessionFactory)); services.AddSingleton(typeof(IHttpReader), new HttpReader( sessionFactory, httpParser, config, loggerFactory.CreateLogger <HttpReader>())); }
public HttpReader( SessionFactory sessionFactory, HttpQueryParser httpQueryParser, IConfigurationProvider config, ILogger <HttpReader> logger) { _logger = logger; _sessionFactory = sessionFactory; _httpQueryParser = httpQueryParser; _config = config; }
public async Task <string> Format(HttpRequest request, IModel <string> tokenizer) { var parser = new HttpQueryParser(new QueryParser <string>(_sessionFactory, tokenizer, _log)); var query = await parser.ParseRequest(request); var dictionary = new Dictionary <string, object>(); parser.ParseQuery(query, dictionary); return(JsonConvert.SerializeObject(dictionary, Formatting.Indented)); }