From ecd20b1828a932e2e75ab3fe82c05d77435b5898 Mon Sep 17 00:00:00 2001 From: Robbware Date: Tue, 3 Oct 2023 12:30:48 +0100 Subject: [PATCH] Use constants for the property names on the configuration files for BookInputConfiguration --- .gitignore | 3 +++ .../BookEditor/InputEditor.razor.cs | 23 +++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 555c63090..c2732183b 100644 --- a/.gitignore +++ b/.gitignore @@ -349,3 +349,6 @@ MigrationBackup/ # Ionide (cross platform F# VS Code tools) working folder .ionide/ /COMETwebapp/Tools + +# Jetbrains folders +.idea/ \ No newline at end of file diff --git a/COMET.Web.Common/Components/BookEditor/InputEditor.razor.cs b/COMET.Web.Common/Components/BookEditor/InputEditor.razor.cs index 35cd9c7b1..73c6435b0 100644 --- a/COMET.Web.Common/Components/BookEditor/InputEditor.razor.cs +++ b/COMET.Web.Common/Components/BookEditor/InputEditor.razor.cs @@ -85,16 +85,26 @@ public partial class InputEditor [Parameter] public IEnumerable AvailableCategories { get; set; } - /// - /// Sets if the component should show the name field + /// + /// Sets if the component should show the name field /// private bool showName; - /// - /// Sets if the component should show the shorname field + /// + /// The name of the ShowName property on the configuration file + /// + private const string showNameConfigurationProperty = "ShowName"; + + /// + /// Sets if the component should show the shorname field /// private bool showShortName; + /// + /// The name of the ShowShortName property on the configuration file + /// + private const string showShortNameConfigurationProperty = "ShowShortName"; + /// /// Method invoked when the component is ready to start, having received its /// initial parameters from its parent in the render tree. @@ -115,12 +125,12 @@ protected override async Task OnInitializedAsync() var jsonContent = await this.HttpClient.GetStreamAsync(path); var configurations = JsonSerializer.Deserialize>(jsonContent); - if (configurations.TryGetValue("ShowName", out var showNameValue)) + if (configurations.TryGetValue(showNameConfigurationProperty, out var showNameValue)) { this.showName = showNameValue; } - if (configurations.TryGetValue("ShowShortName", out var showShortNameValue)) + if (configurations.TryGetValue(showShortNameConfigurationProperty, out var showShortNameValue)) { this.showShortName = showShortNameValue; } @@ -133,7 +143,6 @@ protected override async Task OnInitializedAsync() catch (Exception e) { this.Logger.LogError(e, "Error while getting the configuration file."); - return; } }