internal ActionBuilderMapping(MethodInfo method, ActionApiVersionConventionBuilder builder) { Contract.Requires(method != null); Contract.Requires(builder != null); Method = method; Builder = builder; }
/// <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); }
/// <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); }
/// <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); }
/// <summary> /// Attempts to retrieve the controller action convention builder for the specified method. /// </summary> /// <param name="actionMethod">The controller action method to get the convention builder for.</param> /// <param name="actionBuilder">The <see cref="ActionApiVersionConventionBuilder{T}">controller action convention builder</see> or <c>null</c>.</param> /// <returns>True if the <paramref name="actionBuilder">action builder</paramref> is successfully retrieved; otherwise, false.</returns> public virtual bool TryGetValue(MethodInfo actionMethod, out ActionApiVersionConventionBuilder <T> actionBuilder) { actionBuilder = null; if (actionMethod == null) { return(false); } var mapping = actionBuilderMappings.FirstOrDefault(m => m.Method == actionMethod); return((actionBuilder = mapping?.Builder) != null); }
/// <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); }
public virtual ActionApiVersionConventionBuilder <T> Action(MethodInfo actionMethod) { Arg.NotNull(actionMethod, nameof(actionMethod)); Contract.Ensures(Contract.Result <ActionApiVersionConventionBuilder <T> >() != null); var key = actionMethod.GetHashCode(); var actionBuilder = default(ActionApiVersionConventionBuilder <T>); if (!ActionBuilders.TryGetValue(key, out actionBuilder)) { ActionBuilders[key] = actionBuilder = new ActionApiVersionConventionBuilder <T>(this); } return(actionBuilder); }
/// <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); }
internal ActionBuilderMapping(MethodInfo method, ActionApiVersionConventionBuilder <T> builder) { Method = method; Builder = builder; }