-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: improve configuration handling readability
- Loading branch information
1 parent
f931348
commit b9b18fd
Showing
8 changed files
with
93 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
// (c) 2021 Francesco Del Re <[email protected]> | ||
// This code is licensed under MIT license (see LICENSE.txt for details) | ||
using Microsoft.Extensions.Configuration; | ||
using SharpConnector.Interfaces; | ||
using System.Linq; | ||
using SharpConnector.Enums; | ||
using SharpConnector.Interfaces; | ||
using System; | ||
|
||
namespace SharpConnector.Configuration | ||
{ | ||
/// <summary> | ||
/// RavenDbConfig configuration class. | ||
/// Provides configuration settings for RavenDB. | ||
/// </summary> | ||
public class RavenDbConfig : IConnectorConfig | ||
{ | ||
public string ConnectionString { get; } | ||
public string DatabaseName { get; } | ||
|
||
// Not used | ||
#region NOT USED | ||
public string CollectionName { get; private set; } | ||
public int DatabaseNumber { get; private set; } | ||
public string Username { get; private set; } | ||
|
@@ -27,17 +27,17 @@ public class RavenDbConfig : IConnectorConfig | |
public string ServiceUrl { get; private set; } | ||
public bool UseHttp { get; private set; } | ||
public string TableName { get; private set; } | ||
#endregion | ||
|
||
public RavenDbConfig(IConfiguration section) | ||
public RavenDbConfig(IConfiguration configuration) | ||
{ | ||
var sectionChildren = section.GetChildren(); | ||
var configurationSections = sectionChildren.ToList(); | ||
|
||
var sectionChildrenConnectionString = configurationSections.FirstOrDefault(s => s.Key.ToLower() == AppConfigParameterEnums.connectionstring.ToString()); | ||
ConnectionString = sectionChildrenConnectionString?.Value; | ||
if (configuration == null) | ||
{ | ||
throw new ArgumentNullException(nameof(configuration)); | ||
} | ||
|
||
var sectionChildrenDatabaseName = configurationSections.FirstOrDefault(s => s.Key.ToLower() == AppConfigParameterEnums.databasename.ToString()); | ||
DatabaseName = sectionChildrenDatabaseName?.Value.Trim(); | ||
ConnectionString = configuration[AppConfigParameterEnums.connectionstring.ToString()]?.Trim(); | ||
DatabaseName = configuration[AppConfigParameterEnums.databasename.ToString()]?.Trim(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters