示例#1
0
    /// <summary>
    /// Adds the core Piranha services if simple startup is used.
    /// </summary>
    /// <param name="services">The current service collection</param>
    /// <param name="options">The builder options</param>
    /// <returns>The updated service collection</returns>
    public static IServiceCollection AddPiranha(this IServiceCollection services, Action <PiranhaServiceBuilder> options)
    {
        var serviceBuilder = new PiranhaServiceBuilder(services);

        options?.Invoke(serviceBuilder);

        var config = new PiranhaRouteConfig
        {
            UseAliasRouting     = serviceBuilder.UseAliasRouting,
            UseArchiveRouting   = serviceBuilder.UseArchiveRouting,
            UsePageRouting      = serviceBuilder.UsePageRouting,
            UsePostRouting      = serviceBuilder.UsePostRouting,
            UseSiteRouting      = serviceBuilder.UseSiteRouting,
            UseSitemapRouting   = serviceBuilder.UseSitemapRouting,
            UseStartpageRouting = serviceBuilder.UseStartpageRouting
        };

        services.AddSingleton <PiranhaRouteConfig>(config);

        services.AddControllersWithViews();
        var mvcBuilder = services.AddRazorPages();

        if (serviceBuilder.AddRazorRuntimeCompilation)
        {
            mvcBuilder.AddRazorRuntimeCompilation();
        }
        services.AddPiranha();
        services.AddPiranhaApplication();

        return(serviceBuilder.Services);
    }
示例#2
0
    /// <summary>
    /// Adds the core Piranha services if simple startup is used.
    /// </summary>
    /// <param name="services">The current service collection</param>
    /// <param name="options">The builder options</param>
    /// <returns>The updated service collection</returns>
    public static IServiceCollection AddPiranha(this IServiceCollection services, Action <PiranhaServiceBuilder> options)
    {
        var serviceBuilder = new PiranhaServiceBuilder(services);

        options?.Invoke(serviceBuilder);

        var config = new PiranhaRouteConfig
        {
            LoginUrl            = serviceBuilder.LoginUrl,
            UseAliasRouting     = serviceBuilder.UseAliasRouting,
            UseArchiveRouting   = serviceBuilder.UseArchiveRouting,
            UsePageRouting      = serviceBuilder.UsePageRouting,
            UsePostRouting      = serviceBuilder.UsePostRouting,
            UseSiteRouting      = serviceBuilder.UseSiteRouting,
            UseSitemapRouting   = serviceBuilder.UseSitemapRouting,
            UseStartpageRouting = serviceBuilder.UseStartpageRouting
        };

        services.AddSingleton <PiranhaRouteConfig>(config);

        services.AddControllersWithViews();
        var mvcBuilder = services.AddRazorPages();

        if (serviceBuilder.AddRazorRuntimeCompilation)
        {
            mvcBuilder.AddRazorRuntimeCompilation();
        }
        services
        .AddPiranha()
        .AddScoped <Piranha.AspNetCore.Services.IApplicationService, Piranha.AspNetCore.Services.ApplicationService>()
        .AddScoped <Piranha.AspNetCore.Services.IModelLoader, Piranha.AspNetCore.Services.ModelLoader>()
        .AddAuthorization(o =>
        {
            o.AddPolicy(Permission.PagePreview, policy =>
            {
                policy.RequireClaim(Permission.PagePreview, Permission.PagePreview);
            });
            o.AddPolicy(Permission.PostPreview, policy =>
            {
                policy.RequireClaim(Permission.PostPreview, Permission.PostPreview);
            });
        });
        return(serviceBuilder.Services);
    }
 /// <summary>
 /// Creates a new middleware instance.
 /// </summary>
 /// <param name="next">The next middleware in the pipeline</param>
 /// <param name="config">The current route configuration</param>
 /// <param name="factory">The logger factory</param>
 public IntegratedMiddleware(RequestDelegate next, PiranhaRouteConfig config, ILoggerFactory factory = null) : base(next, factory)
 {
     _config = config;
 }
 /// <summary>
 /// Creates a new middleware instance.
 /// </summary>
 /// <param name="next">The next middleware in the pipeline</param>
 /// <param name="factory">The logger factory</param>
 /// <param name="config">The optional route config</param>
 public SitemapMiddleware(RequestDelegate next, ILoggerFactory factory = null, PiranhaRouteConfig config = null) : base(next, factory)
 {
     _config = config;
 }
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="next">The next middleware component in the pipeline</param>
 /// <param name="config">The piranha route config</param>
 public SecurityMiddleware(RequestDelegate next, PiranhaRouteConfig config)
 {
     _next   = next;
     _config = config;
 }