Example #1
0
        /// <summary>
        /// Configure services for this API.
        /// </summary>
        /// <param name="apiType">
        /// The Api type.
        /// </param>
        /// <param name="services">
        /// The <see cref="IServiceCollection"/> with which is used to store all services.
        /// </param>
        /// <returns>The <see cref="IServiceCollection"/>.</returns>
        //[CLSCompliant(false)]
        public static IServiceCollection ConfigureApi(Type apiType, IServiceCollection services)
        {
            // Add core and convention's services
            services = services.AddCoreServices(apiType)
                       .AddConventionBasedServices(apiType);

            // This is used to add the publisher's services
            GetPublisherServiceCallback(apiType)(services);

            return(services);
        }
        /// <summary>
        /// Configures the API services for this API. Descendants may override this method to register
        /// <typeparamref name="T"/> as a scoped service.
        /// </summary>
        /// <param name="apiType">
        /// The Api type.
        /// </param>
        /// <param name="services">
        /// The <see cref="IServiceCollection"/> with which to create all DI services.
        /// </param>
        /// <returns>
        /// The <see cref="IServiceCollection"/>.
        /// </returns>
        //[CLSCompliant(false)]
#pragma warning disable CA1000 // Do not declare static members on generic types
        public static new IServiceCollection ConfigureApi(Type apiType, IServiceCollection services)
#pragma warning restore CA1000 // Do not declare static members on generic types
        {
            // Add core and convention's services
            services = services.AddCoreServices(apiType)
                       .AddConventionBasedServices(apiType);

            // Add EF related services
            services.AddEfProviderServices <T>();

            // This is used to add the publisher's services
            GetPublisherServiceCallback(apiType)(services);

            return(services);
        }