Example #1
0
        /// <summary>
        /// Indicates that the specified API version is mapped to the configured controller action.
        /// </summary>
        /// <param name="builder">The extended <see cref="ActionApiVersionConventionBuilder"/>.</param>
        /// <param name="groupVersion">The group version.</param>
        /// <returns>The original <see cref="ActionApiVersionConventionBuilder"/>.</returns>
        public static ActionApiVersionConventionBuilder MapToApiVersion(this ActionApiVersionConventionBuilder builder, DateTime groupVersion)
        {
            Arg.NotNull(builder, nameof(builder));
            Contract.Ensures(Contract.Result <ActionApiVersionConventionBuilder>() != null);

            builder.MapToApiVersion(new ApiVersion(groupVersion));
            return(builder);
        }
Example #2
0
        /// <summary>
        /// Indicates that the specified API version is mapped to the configured controller action.
        /// </summary>
        /// <param name="builder">The extended <see cref="ActionApiVersionConventionBuilder"/>.</param>
        /// <param name="majorVersion">The value for a major version only scheme.</param>
        /// <param name="status">The version status.</param>
        /// <returns>The original <see cref="ActionApiVersionConventionBuilder"/>.</returns>
        public static ActionApiVersionConventionBuilder MapToApiVersion(this ActionApiVersionConventionBuilder builder, int majorVersion, string status)
        {
            Arg.NotNull(builder, nameof(builder));
            Contract.Ensures(Contract.Result <ActionApiVersionConventionBuilder>() != null);
            Arg.GreaterThanOrEqualTo(majorVersion, 0, nameof(majorVersion));

            builder.MapToApiVersion(new ApiVersion(majorVersion, 0, status));
            return(builder);
        }
        /// <summary>
        /// Indicates that the specified API version is mapped to the configured controller action.
        /// </summary>
        /// <typeparam name="T">The type of controller.</typeparam>
        /// <param name="builder">The extended <see cref="ActionApiVersionConventionBuilder{T}"/>.</param>
        /// <param name="groupVersion">The group version.</param>
        /// <returns>The original <see cref="ActionApiVersionConventionBuilder{T}"/>.</returns>
        public static ActionApiVersionConventionBuilder <T> MapToApiVersion <T>(this ActionApiVersionConventionBuilder <T> builder, DateTime groupVersion)
#if WEBAPI
            where T : IHttpController
#endif
        {
            Arg.NotNull(builder, nameof(builder));
            Contract.Ensures(Contract.Result <ActionApiVersionConventionBuilder <T> >() != null);

            builder.MapToApiVersion(new ApiVersion(groupVersion));
            return(builder);
        }
Example #4
0
        /// <summary>
        /// Indicates that the specified API version is mapped to the configured controller action.
        /// </summary>
        /// <param name="builder">The extended <see cref="ActionApiVersionConventionBuilder"/>.</param>
        /// <param name="year">The version year.</param>
        /// <param name="month">The version month.</param>
        /// <param name="day">The version day.</param>
        /// <returns>The original <see cref="ActionApiVersionConventionBuilder"/>.</returns>
        public static ActionApiVersionConventionBuilder MapToApiVersion(this ActionApiVersionConventionBuilder builder, int year, int month, int day)
        {
            Arg.NotNull(builder, nameof(builder));
            Contract.Ensures(Contract.Result <ActionApiVersionConventionBuilder>() != null);
            Arg.InRange(year, 1, 9999, nameof(year));
            Arg.InRange(month, 1, 12, nameof(month));
            Arg.InRange(day, 1, 31, nameof(day));

            builder.MapToApiVersion(new ApiVersion(new DateTime(year, month, day)));
            return(builder);
        }
        /// <summary>
        /// Indicates that the specified API version is mapped to the configured controller action.
        /// </summary>
        /// <typeparam name="T">The type of controller.</typeparam>
        /// <param name="builder">The extended <see cref="ActionApiVersionConventionBuilder{T}"/>.</param>
        /// <param name="majorVersion">The value for a major version only scheme.</param>
        /// <param name="status">The version status.</param>
        /// <returns>The original <see cref="ActionApiVersionConventionBuilder{T}"/>.</returns>
        public static ActionApiVersionConventionBuilder <T> MapToApiVersion <T>(this ActionApiVersionConventionBuilder <T> builder, int majorVersion, string status)
#if WEBAPI
            where T : IHttpController
#endif
        {
            Arg.NotNull(builder, nameof(builder));
            Contract.Ensures(Contract.Result <ActionApiVersionConventionBuilder <T> >() != null);
            Arg.GreaterThanOrEqualTo(majorVersion, 0, nameof(majorVersion));

            builder.MapToApiVersion(new ApiVersion(majorVersion, 0, status));
            return(builder);
        }
Example #6
0
        /// <summary>
        /// Indicates that the specified API versions are mapped to the configured controller action.
        /// </summary>
        /// <param name="builder">The extended <see cref="ActionApiVersionConventionBuilder"/>.</param>
        /// <param name="apiVersions">The <see cref="IEnumerable{T}">sequence</see> of <see cref="ApiVersion">API versions</see> supported by the controller.</param>
        /// <returns>The original <see cref="ActionApiVersionConventionBuilder"/>.</returns>
        public static ActionApiVersionConventionBuilder MapToApiVersions(this ActionApiVersionConventionBuilder builder, IEnumerable <ApiVersion> apiVersions)
        {
            Arg.NotNull(builder, nameof(builder));
            Arg.NotNull(apiVersions, nameof(apiVersions));
            Contract.Ensures(Contract.Result <ActionApiVersionConventionBuilder>() != null);

            foreach (var apiVersion in apiVersions)
            {
                builder.MapToApiVersion(apiVersion);
            }

            return(builder);
        }
        /// <summary>
        /// Indicates that the specified API version is mapped to the configured controller action.
        /// </summary>
        /// <typeparam name="T">The type of controller.</typeparam>
        /// <param name="builder">The extended <see cref="ActionApiVersionConventionBuilder{T}"/>.</param>
        /// <param name="year">The version year.</param>
        /// <param name="month">The version month.</param>
        /// <param name="day">The version day.</param>
        /// <returns>The original <see cref="ActionApiVersionConventionBuilder{T}"/>.</returns>
        public static ActionApiVersionConventionBuilder <T> MapToApiVersion <T>(this ActionApiVersionConventionBuilder <T> builder, int year, int month, int day)
#if WEBAPI
            where T : IHttpController
#endif
        {
            Arg.NotNull(builder, nameof(builder));
            Contract.Ensures(Contract.Result <ActionApiVersionConventionBuilder <T> >() != null);
            Arg.InRange(year, 1, 9999, nameof(year));
            Arg.InRange(month, 1, 12, nameof(month));
            Arg.InRange(day, 1, 31, nameof(day));

            builder.MapToApiVersion(new ApiVersion(new DateTime(year, month, day)));
            return(builder);
        }
        /// <summary>
        /// Indicates that the specified API versions are mapped to the configured controller action.
        /// </summary>
        /// <typeparam name="T">The type of controller.</typeparam>
        /// <param name="builder">The extended <see cref="ActionApiVersionConventionBuilder{T}"/>.</param>
        /// <param name="apiVersions">The <see cref="IEnumerable{T}">sequence</see> of <see cref="ApiVersion">API versions</see> supported by the controller.</param>
        /// <returns>The original <see cref="ActionApiVersionConventionBuilder{T}"/>.</returns>
        public static ActionApiVersionConventionBuilder <T> MapToApiVersions <T>(this ActionApiVersionConventionBuilder <T> builder, IEnumerable <ApiVersion> apiVersions)
#if WEBAPI
            where T : IHttpController
#endif
        {
            Arg.NotNull(builder, nameof(builder));
            Arg.NotNull(apiVersions, nameof(apiVersions));
            Contract.Ensures(Contract.Result <ActionApiVersionConventionBuilder <T> >() != null);

            foreach (var apiVersion in apiVersions)
            {
                builder.MapToApiVersion(apiVersion);
            }

            return(builder);
        }