public void ConfigureServices(IServiceCollection services) { services.AddCors(options => { options.AddPolicy("AllowAll", p => p .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader()); }); // initializes plugin type services.AddPlugin(Configuration) .AddRouting(options => services.ConfigurePluginRouting(options)) .ConfigurePluginServices(); bool isHttpFunction = services.Any(x => x.ServiceType == typeof(IHttpFunction)); IPluginStartup pluginStartup = isHttpFunction ? new Functions.Startup(Configuration) : new Api.Startup(Configuration); pluginStartup.ConfigureServices(services); configure = pluginStartup.Configure; }
static Plugin configureServices(Assembly assembly, IServiceCollection services) { Plugin plugin = null; foreach (Type type in assembly.GetTypes()) { if (typeof(IPluginStartup).IsAssignableFrom(type)) { IPluginStartup pluginStartup = Activator.CreateInstance(type) as IPluginStartup; if (pluginStartup != null) { pluginStartup.ConfigureServices(services); plugin = new Plugin { AreaName = pluginStartup.AreaName, Assembly = assembly }; } } } return(plugin); }