//This method gets called by the runtime.Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(opt => opt.AddDefaultPolicy(p => { p.AllowAnyHeader(); p.AllowAnyMethod(); p.AllowAnyOrigin(); })); var ass = new List <Assembly>(); var builder = services.AddMvc().AddJsonOptions(options => { options.SerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter()); options.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore; }); var pluginPath = Configuration.GetValue <string>("PluginPath"); logger.LogInformation($"loading plugins from {pluginPath}"); Console.WriteLine($"loading plugins from {pluginPath}"); List <Assembly> allAssembly = AssemblyHelper.GetAllAssembly(); ReflectionManager rm = new ReflectionManager(allAssembly); appEngine = AppEngine.Create( pluginPath, loggerFactory.CreateLogger <AppEngine>(), rm, services, Configuration); appEngine.InvokeConfigureServices(ass, builder, services, Configuration); foreach (var a in ass.Distinct()) { builder.AddApplicationPart(a).AddControllersAsServices(); } services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "Web API", Version = "v1" }); //x.IncludeXmlComments(AppContext.BaseDirectory + "YourProject.Api.xml"); c.IgnoreObsoleteProperties(); c.IgnoreObsoleteActions(); c.DescribeAllEnumsAsStrings(); c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First()); c.CustomSchemaIds(t => t.FullName); }); //Invoke appEngine after service configuration appEngine.InvokePostConfigureServices(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var ass = new List <Assembly>(); var builder = services.AddMvc(); var pluginPath = Configuration.GetValue <string>("PluginPath"); List <Assembly> allAssembly = AssemblyHelper.GetAllAssembly(); ReflectionManager rm = new ReflectionManager(allAssembly); appEngine = AppEngine.Create( pluginPath, loggerFactory.CreateLogger <AppEngine>(), rm, services, Configuration); appEngine.InvokeConfigureServices(ass, builder, services, Configuration); foreach (var a in ass.Distinct()) { builder.AddApplicationPart(a).AddControllersAsServices(); } services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "Web API", Version = "v1" }); //x.IncludeXmlComments(AppContext.BaseDirectory + "YourProject.Api.xml"); c.IgnoreObsoleteProperties(); c.IgnoreObsoleteActions(); c.DescribeAllEnumsAsStrings(); c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First()); c.CustomSchemaIds(t => t.FullName); }); //Invoke appEngine after service configuration appEngine.InvokePostConfigureServices(services); }