oqtane.framework/Oqtane.Client/Shared/ModuleInstance.razor
2019-08-27 17:14:41 -04:00

45 lines
1.3 KiB
Plaintext

@using Oqtane.Models
@using Oqtane.Shared
@using Oqtane.Modules
@DynamicComponent
@code {
[CascadingParameter]
protected PageState PageState { get; set; }
[CascadingParameter]
private Module ModuleState { get; set; }
RenderFragment DynamicComponent { get; set; }
protected override void OnInitialized()
{
DynamicComponent = builder =>
{
string typename = ModuleState.ModuleType;
if (PageState.Control == "Settings") // module settings are a core component
{
typename = Constants.DefaultSettingsControl;
}
Type moduleType = null;
if (typename != null)
{
moduleType = Type.GetType(typename);
}
if (moduleType != null)
{
builder.OpenComponent(0, moduleType);
builder.CloseComponent();
}
else
{
// module does not exist with typename specified
builder.OpenComponent(0, Type.GetType(Constants.ModuleMessageControl));
builder.AddAttribute(1, "Message", "Error Loading Component For Module " + ModuleState.ModuleDefinitionName);
builder.CloseComponent();
}
};
}
}