@namespace Oqtane.UI @inject IStringLocalizer Localizer @if (ModuleType != null) { @if (_progressIndicator) {
} }
@code { private string _message; private MessageType _messageType; private bool _progressIndicator = false; private Type ModuleType { get; set; } private IDictionary ModuleParameters { get; set; } [CascadingParameter] protected PageState PageState { get; set; } [CascadingParameter] private Module ModuleState { get; set; } private ModuleMessage ModuleMessage { get; set; } private RenderFragment DynamicComponent { get; set; } protected override void OnParametersSet() { _message = ""; if (!string.IsNullOrEmpty(ModuleState.ModuleType)) { ModuleType = Type.GetType(ModuleState.ModuleType); if (ModuleType != null) { ModuleParameters = new Dictionary { { "ModuleInstance", this } }; return; } // module does not exist with typename specified _message = string.Format(Localizer["Error.Module.InvalidName"], Utilities.GetTypeNameLastSegment(ModuleState.ModuleType, 0)); _messageType = MessageType.Error; } else { _message = string.Format(Localizer["Error.Module.InvalidType"], ModuleState.ModuleDefinitionName); _messageType = MessageType.Error; } } public void AddModuleMessage(string message, MessageType type) { _message = message; _messageType = type; _progressIndicator = false; StateHasChanged(); } public void ShowProgressIndicator() { _progressIndicator = true; StateHasChanged(); } public void HideProgressIndicator() { _progressIndicator = false; StateHasChanged(); } private string ErrorMessage(Exception context) { var message = string.Format(Localizer["Error.Module.Exception"], ModuleState.ModuleDefinitionName); if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host)) { return $"{message}
{context}"; } return message; } }