You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Connected.Framework/Connected.Configuration/Environment/EnvironmentService.cs

34 lines
789 B

2 years ago
using System.Collections.Immutable;
using System.Reflection;
using Connected.Annotations;
namespace Connected.Configuration.Environment;
internal class EnvironmentService : IEnvironmentService
{
private List<Assembly>? _assemblies;
public List<Assembly> All => _assemblies ??= QueryAssemblies();
public EnvironmentService()
{
Services = new EnvironmentServices();
}
public ImmutableList<Assembly> MicroServices => All.ToImmutableList();
public IEnvironmentServices Services { get; }
private static List<Assembly> QueryAssemblies()
{
var result = new List<Assembly>();
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
if (assembly.GetCustomAttribute<MicroServiceAttribute>() is not null)
result.Add(assembly);
}
return result;
}
}