public static RhetosAspNetServiceCollectionBuilder AddHomePage(this RhetosAspNetServiceCollectionBuilder rhetosBuilder, Type homePageViewComponentSnippet = null)
        {
            rhetosBuilder.Services
            .AddControllersWithViews()
            .AddApplicationPart(typeof(RhetosHomePageController).Assembly);

            rhetosBuilder.Services.AddOptions();
            if (homePageViewComponentSnippet != null)
            {
                rhetosBuilder.Services.Configure <RhetosHomeViewComponentOptions>(o => o.HomeViewComponents.Add(homePageViewComponentSnippet));
            }

            return(rhetosBuilder);
        }
        public static RhetosAspNetServiceCollectionBuilder AddRestApi(this RhetosAspNetServiceCollectionBuilder builder,
                                                                      Action <RestApiOptions> configureOptions, Action <ControllerRestInfoRepository> onControllerRestInfoCreated = null)
        {
            var options = new RestApiOptions()
            {
                BaseRoute = "RhetosRestApi",
                ConceptInfoRestMetadataProviders = new List <IConceptInfoRestMetadataProvider>(_defaultMetadataProviders)
            };

            configureOptions?.Invoke(options);

            builder.Services.TryAddScoped <QueryParameters>();
            builder.Services.TryAddScoped <ServiceUtility>();
            builder.Services.TryAddScoped <JsonErrorHandler>();

            builder.Services.TryAddScoped <ApiExceptionFilter>();
            builder.Services.TryAddScoped <ApiCommitOnSuccessFilter>();

            var controllerRepository = CreateControllerRestInfoRepository(builder.RhetosHost, options);

            onControllerRestInfoCreated?.Invoke(controllerRepository);

            builder.Services.AddSingleton(controllerRepository);

            builder.Services
            .AddControllers(o =>
            {
                o.Conventions.Add(new RestApiControllerRouteConvention(options, controllerRepository));
            })
            .ConfigureApplicationPartManager(p =>
            {
                p.FeatureProviders.Add(new RestApiControllerFeatureProvider(controllerRepository));
            });

            return(builder);
        }
Example #3
0
 public static RhetosAspNetServiceCollectionBuilder AddSampleSnippets(this RhetosAspNetServiceCollectionBuilder rhetosBuilder)
 {
     rhetosBuilder.AddHomePage(typeof(DemoComponent));
     rhetosBuilder.AddHomePage(typeof(DemoComponent2));
     return(rhetosBuilder);
 }
 public static RhetosAspNetServiceCollectionBuilder AddRhetosSwaggerGen(this RhetosAspNetServiceCollectionBuilder builder)
 {
     builder.Services.AddTransient <IConfigureOptions <SwaggerGenOptions>, ConfigureSwaggerGenOptions>();
     return(builder);
 }