Skip to content

Commit

Permalink
Use constants for the property names on the configuration files for B…
Browse files Browse the repository at this point in the history
…ookInputConfiguration
  • Loading branch information
Robbware committed Oct 3, 2023
1 parent e3a0adf commit aeed121
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,6 @@ MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
/COMETwebapp/Tools

# Jetbrains folders
.idea/
23 changes: 16 additions & 7 deletions COMET.Web.Common/Components/BookEditor/InputEditor.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,26 @@ public partial class InputEditor<TItem>
[Parameter]
public IEnumerable<Category> AvailableCategories { get; set; }

/// <summary>
/// Sets if the component should show the name field
/// <summary>
/// Sets if the component should show the name field
/// </summary>
private bool showName;

/// <summary>
/// Sets if the component should show the shorname field
/// <summary>
/// The name of the ShowName property on the configuration file
/// </summary>
private const string showNameConfigurationProperty = "ShowName";

/// <summary>
/// Sets if the component should show the shorname field
/// </summary>
private bool showShortName;

/// <summary>
/// The name of the ShowShortName property on the configuration file
/// </summary>
private const string showShortNameConfigurationProperty = "ShowShortName";

/// <summary>
/// Method invoked when the component is ready to start, having received its
/// initial parameters from its parent in the render tree.
Expand All @@ -115,12 +125,12 @@ protected override async Task OnInitializedAsync()
var jsonContent = await this.HttpClient.GetStreamAsync(path);
var configurations = JsonSerializer.Deserialize<Dictionary<string, bool>>(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;
}
Expand All @@ -133,7 +143,6 @@ protected override async Task OnInitializedAsync()
catch (Exception e)
{
this.Logger.LogError(e, "Error while getting the configuration file.");
return;
}
}

Expand Down

0 comments on commit aeed121

Please sign in to comment.