Skip to content

Commit

Permalink
Since the addition of Dependency Injection, the priority order is cau…
Browse files Browse the repository at this point in the history
…sing issue with Service Ordering. Removing the feature to order services by priority until it can be updated to work better with DI (ordering services by dependency need).

Also added some log clean-up
  • Loading branch information
SimonDarksideJ committed Nov 20, 2024
1 parent 3acf478 commit fa64556
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions Runtime/Services/ServiceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,7 @@ private void InitializeServiceLocator(GameObject instance = null)

if (ActiveProfile?.ServiceConfigurations != null)
{
var orderedConfig = ActiveProfile.ServiceConfigurations.OrderBy(s => s.Priority).ToArray();
TryRegisterServiceConfigurations(orderedConfig);
TryRegisterServiceConfigurations(ActiveProfile.ServiceConfigurations);
}

var activeSceneName = SceneManager.GetActiveScene().name;
Expand Down Expand Up @@ -779,20 +778,17 @@ private bool TryInjectDependentServices(Type concreteType, ref object[] args)
return true;
}

Debug.Log($"Constructor: {primaryConstructor}");

foreach (var parameter in parameters)
{
if (parameter.ParameterType.IsInterface && typeof(IService).IsAssignableFrom(parameter.ParameterType))
{
if (TryGetService(parameter.ParameterType, out var dependency))
{
Debug.Log($"Injecting {dependency.Name} into {parameter.Name}");
args = args.AddItem(dependency);
}
else
{
Debug.LogError($"Failed to find an {parameter.ParameterType.Name} service to inject into {parameter.Name}!");
Debug.LogError($"Failed to find an {parameter.ParameterType.Name} service to inject into parameter {parameter.Name} for service {concreteType.Name}!");
}
}
}
Expand Down

0 comments on commit fa64556

Please sign in to comment.