예제 #1
0
        public RouteVersionConstraint(string version, bool isDefault, RouteVersionsOptions options)
        {
            Version   = version ?? throw new ArgumentNullException(nameof(version));
            IsDefault = isDefault;
            _options  = options ?? throw new ArgumentNullException(nameof(options));

            _acceptHeaderRegex = new Regex(options.AcceptRegexPattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
        }
예제 #2
0
        public static void ConfigureRouteVersions(
            this IServiceCollection services,
            RouteVersionsOptions options)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            services.TryAddSingleton(options);
        }
예제 #3
0
        public static void ConfigureRouteVersions(
            this IServiceCollection services,
            Action <RouteVersionsOptions> configureRouteVersions)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }
            if (configureRouteVersions == null)
            {
                throw new ArgumentNullException(nameof(configureRouteVersions));
            }

            var options = new RouteVersionsOptions();

            configureRouteVersions(options);

            services.ConfigureRouteVersions(options);
        }