/// <summary> /// Creates a new instance of the <see cref="CorsService"/>. /// </summary> /// <param name="options">The option model representing <see cref="CorsOptions"/>.</param> public CorsService(IOptions<CorsOptions> options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } _options = options.Value; }
public void BuildControllerModel_EnableCorsAttributeAddsCorsAuthorizationFilterFactory() { // Arrange var corsOptions = new CorsOptions(); corsOptions.AddPolicy("policy", new CorsPolicy()); var mockOptions = new Mock<IOptions<CorsOptions>>(); mockOptions.SetupGet(o => o.Options) .Returns(corsOptions); var builder = new DefaultControllerModelBuilder(new DefaultActionModelBuilder(null), authorizationOptions: null); var typeInfo = typeof(CorsController).GetTypeInfo(); // Act var model = builder.BuildControllerModel(typeInfo); // Assert Assert.Single(model.Filters, f => f is CorsAuthorizationFilterFactory); }
/// <summary> /// Creates a new instance of the <see cref="CorsService"/>. /// </summary> /// <param name="options">The option model representing <see cref="CorsOptions"/>.</param> public CorsService([NotNull] IOptions<CorsOptions> options) { _options = options.Options; }
/// <summary> /// Creates a new instance of <see cref="DefaultCorsPolicyProvider"/>. /// </summary> /// <param name="options">The options configured for the application.</param> public DefaultCorsPolicyProvider(IOptions<CorsOptions> options) { _options = options.Value; }
/// <summary> /// Creates a new instance of the <see cref="CorsService"/>. /// </summary> /// <param name="options">The option model representing <see cref="CorsOptions"/>.</param> public CorsService([NotNull] IOptions <CorsOptions> options) { _options = options.Options; }
/// <summary> /// Creates a new instance of <see cref="DefaultCorsPolicyProvider"/>. /// </summary> /// <param name="options">The options configured for the application.</param> public DefaultCorsPolicyProvider(IOptions <CorsOptions> options) { _options = options.Options; }