Skip to content

Commit

Permalink
🔧 (MigrationTools.sln): add appsettings.json to solution items
Browse files Browse the repository at this point in the history
📝 (MigrationTools.xml): update XML documentation with new commit details
♻️ (ServiceCollectionExtensions): refactor endpoint configuration to prevent multiple registrations

Adding `appsettings.json` to the solution items ensures it is tracked and managed within the solution, improving configuration management. The XML documentation is updated to reflect the latest commit details, ensuring accurate reference information. The refactoring in `ServiceCollectionExtensions` prevents multiple registrations of endpoints by introducing a check to see if they have already been configured, enhancing the efficiency and reliability of the service registration process.
  • Loading branch information
MrHinsh committed Sep 16, 2024
1 parent 76c49c7 commit 8d4a8c0
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
1 change: 1 addition & 0 deletions MigrationTools.sln
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
.gitattributes = .gitattributes
.gitignore = .gitignore
appsettings.json = appsettings.json
configuration.json = configuration.json
configuration2-wit.json = configuration2-wit.json
configuration2.json = configuration2.json
Expand Down
14 changes: 7 additions & 7 deletions docs/Reference/Generated/MigrationTools.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ public static partial class ServiceCollectionExtensions
{
public static void AddMigrationToolServicesForClientAzureDevopsRest(this IServiceCollection context, IConfiguration configuration)
{
context.AddConfiguredEndpoints(configuration);

//TfsPipelines
context.AddTransient<AzureDevOpsPipelineProcessor>();
context.AddTransient<ProcessDefinitionProcessor>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public static void AddMigrationToolServicesForClientAzureDevOpsObjectModel(this
context.AddTransient<TfsTeamSettingsProcessor>();
context.AddTransient<TfsSharedQueryProcessor>();

context.AddConfiguredEndpoints(configuration);

context.AddMigrationToolServicesForClientTfs_Tools(configuration);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@ namespace MigrationTools
{
public static class EndpointRegistrationExtensions
{
private static bool configured = false;

public static void AddConfiguredEndpoints(this IServiceCollection services, IConfiguration configuration)
{
if (configured)
{
return;
}
var endpointsSection = configuration.GetSection("MigrationTools:Endpoints");
foreach (var endpointConfig in endpointsSection.GetChildren())
{
var endpointName = endpointConfig.Key;
var endpointType = endpointConfig.GetValue<string>("EndpointType");
if (string.IsNullOrEmpty(endpointType))
{
Log.Warning("Endpoint '{EndpointName}' does not have a type configured. Skipping.", endpointName);
Console.WriteLine("Endpoint '{EndpointName}' does not have a type configured. Skipping.", endpointName);
continue;
}
AddEndPointSingleton(services, configuration, endpointConfig, endpointName, endpointType);
Expand Down
2 changes: 1 addition & 1 deletion src/MigrationTools/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static void AddMigrationToolServices(this IServiceCollection context, ICo



context.AddConfiguredEndpoints(configuration);
context.AddConfiguredEndpoints(configuration); //keep this one
//Containers
context.AddTransient<ProcessorEnricherContainer>();
context.AddTransient<EndpointEnricherContainer>();
Expand Down

0 comments on commit 8d4a8c0

Please sign in to comment.