示例#1
0
    /// <summary>
    /// Adds a <see cref="IParameterModelBaseConvention"/> to all properties and parameters in the application.
    /// </summary>
    /// <param name="conventions">The list of <see cref="IApplicationModelConvention"/>
    /// in <see cref="AspNetCore.Mvc.MvcOptions"/>.</param>
    /// <param name="parameterModelConvention">The <see cref="IParameterModelBaseConvention"/> which needs to be
    /// added.</param>
    public static void Add(
        this IList <IApplicationModelConvention> conventions,
        IParameterModelBaseConvention parameterModelConvention)
    {
        if (conventions == null)
        {
            throw new ArgumentNullException(nameof(conventions));
        }

        if (parameterModelConvention == null)
        {
            throw new ArgumentNullException(nameof(parameterModelConvention));
        }

        conventions.Add(new ParameterBaseApplicationModelConvention(parameterModelConvention));
    }
        /// <summary>
        /// Adds the specified <paramref name="convention"/> to <paramref name="conventions"/>.
        /// The added convention will apply to all handler properties and parameters on handler methods.
        /// </summary>
        /// <param name="conventions">The <see cref="PageConventionCollection"/> to configure.</param>
        /// <param name="convention">The <see cref="IParameterModelBaseConvention"/> to apply.</param>
        /// <returns>The <see cref="PageConventionCollection"/>.</returns>
        public static PageConventionCollection Add(this PageConventionCollection conventions, IParameterModelBaseConvention convention)
        {
            if (conventions == null)
            {
                throw new ArgumentNullException(nameof(conventions));
            }

            if (convention == null)
            {
                throw new ArgumentNullException(nameof(convention));
            }

            var adapter = new ParameterModelBaseConventionAdapter(convention);

            conventions.Add(adapter);
            return(conventions);
        }
 public ParameterModelBaseConventionAdapter(IParameterModelBaseConvention convention)
 {
     _convention = convention;
 }
示例#4
0
 public ParameterBaseApplicationModelConvention(IParameterModelBaseConvention parameterModelBaseConvention)
 {
     _parameterBaseModelConvention = parameterModelBaseConvention;
 }