コード例 #1
0
 public IServiceProvider GetServiceProvider(DataTableLibraryConfiguration libConfig, IDataTablePlacement placement)
 {
     return(new ServiceCollection()
            .AddSingleton(libConfig)
            .AddTransient(sp => httpContextAccessor)
            .AddTransient(sp => dataProtectionProvider)
            .AddTransient <IDataTableRepository>(sp => new DataTableDbContextRepository(libConfig.RepositoryType, libConfig.ConnectionString))
            .AddSingleton <IPlacementContext>(sp => new PlacementContext
     {
         Options = sp.GetRequiredService <IDataTableOptionsProvider>().GetOptions(placement),
         Config = sp.GetRequiredService <IDataTableRepository>()
                  .GetTableConfigAsync(placement.Identifier, placement.UserId)
                  .Result
     })
            .AddTransient <IDataTableOptionsProvider, UrlQueryOptionsProvider>()
            .AddTransient <IDataTableRenderer, HbsRenderer>()
            .AddTransient <IPostContextSerializer, PostContextSerializer>()
            .AddTransient <IDataTableRouter, DataTableRouter>()
            .AddTransient <TableController>()
            .AddTransient <TabListController>()
            .AddTransient <TabFormController>()
            .AddTransient <ControllerFactory>(sp => dataTableMode =>
     {
         return dataTableMode switch
         {
             DataTableMode.Table => sp.GetRequiredService <TableController>(),
             DataTableMode.TabList => sp.GetRequiredService <TabListController>(),
             DataTableMode.CreateTab => sp.GetRequiredService <TabFormController>(),
             _ => throw new NotImplementedException()
         };
     })
            .BuildServiceProvider());
 }
コード例 #2
0
 public DataTableTagHelperExceptionWrapper(IDataTableBootstrap bootstrap, DataTableLibraryConfiguration libConfig)
 {
     this.bootstrap = bootstrap ?? throw new System.ArgumentNullException(nameof(bootstrap));
     this.libConfig = libConfig ?? throw new System.ArgumentNullException(nameof(libConfig));
 }
コード例 #3
0
 public static IServiceCollection AddPanelakDataTable(this IServiceCollection sc, DataTableLibraryConfiguration config)
 {
     return(sc.AddSingleton(config)
            .AddSingleton <DataTableTagHelperExceptionWrapper>()
            .AddTransient <IDataTableBootstrap, DataTableBootstrap>()
            .AddTransient <IPostContextSerializer, PostContextSerializer>()
            .AddDataProtection().Services
            .AddHttpContextAccessor());
 }
コード例 #4
0
 public UrlQueryOptionsProvider(DataTableLibraryConfiguration libConfig, IHttpContextAccessor httpContextAccessor)
 {
     this.libConfig           = libConfig ?? throw new ArgumentNullException(nameof(libConfig));
     this.httpContextAccessor = httpContextAccessor ?? throw new ArgumentNullException(nameof(httpContextAccessor));
 }