HopFrameConfig
The HopFrame config is the global object containing all configurations made for the HopFrame. It is registered as a singleton and can be injected by any service. But it should be treated as a read only dependency because changing the configuration during runtime is not tested and may cause bugs.
Changing the configuration
As already mentioned in the Installation, you configure the HopFrame using the extension method of the IServiceCollection named AddHopFrame. This extension method eiter takes a HopFrameConfig or a configurator action with a HopFrameConfigurator as an argument. You can optionally also provide a LibraryConfiguration for the Fluent UI library and a toggle named addRazorComponents which disables the calls for adding Razor pages with interactive server components if you want to do this yourself.
Mapping the HopFrame pages
In order for the HopFrame pages to be served you need to add them to your application. You can do that in two ways:
Just use the HopFrame as the razor host (Useful for APIs) Just map the HopFrame before you run your application:
app.MapHopFrame();Add the HopFrame to your Razor container (Useful for Blazor web apps) Add the HopFrame to the
MapRazorComponentscall:app.MapRazorComponents<App>() .AddInteractiveServerRenderMode() .AddHopFramePages();
Example
Configuration methods
AddDbContext (With configurator)
Adds all tables defined in the DbContext to the HopFrame UI and configures it using the provided configurator.
Type Parameters:
TDbContext: TheDbContextfrom which all tables should be added.
Parameters:
configurator: Used for configuring theDbContext.
Returns:
HopFrameConfiguratorSee Also: DbContextConfig
AddDbContext (without configurator)
Adds all tables defined in the DbContext to the HopFrame UI and configures it.
Type Parameters:
TDbContext: TheDbContextfrom which all tables should be added.
Returns:
DbContextConfigurator<TDbContext>See Also: DbContextConfig
HasDbContext
Checks if a context is already registered in the HopFrame.
Type Parameters:
TDbContext: The context that should be checked.
Returns:
trueif the context is already registered,falseif not.
GetDbContext
Returns a configurator for the context if it was already defined.
Type Parameters:
TDbContext
Returns: The configurator of the context if it already was defined,
nullif not.
DisplayUserInfo
Determines if the name of the currently logged-in user should be displayed in the top right corner of the admin UI.
Parameters:
display: A boolean value to set if the user info should be displayed.
Returns:
HopFrameConfigurator
SetBasePolicy
Sets a default policy that every user needs to have in order to access the admin UI.
Parameters:
basePolicy: The default policy string.
Returns:
HopFrameConfigurator
SetLoginPage
Sets a custom login page to redirect to if the request to the admin UI was unauthorized.
Parameters:
url: The URL of the custom login page.
Returns:
HopFrameConfigurator