-
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.
- Loading branch information
Showing
6 changed files
with
59 additions
and
9 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
6 changes: 6 additions & 0 deletions
6
src/FieldElementSubsystems/Configuration/ConnectionProtocol.cs
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace EulynxLive.FieldElementSubsystems.Configuration; | ||
|
||
public enum ConnectionProtocol { | ||
EulynxBaseline4R1, | ||
EulynxBaseline4R2 | ||
} |
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,10 +1,33 @@ | ||
using EulynxLive.FieldElementSubsystems.Configuration; | ||
using EulynxLive.FieldElementSubsystems.Interfaces; | ||
|
||
using EulynxBaseline4R1 = EulynxLive.FieldElementSubsystems.Connections.EulynxBaseline4R1; | ||
using EulynxBaseline4R2 = EulynxLive.FieldElementSubsystems.Connections.EulynxBaseline4R2; | ||
|
||
namespace EulynxLive.Point.Connections; | ||
|
||
public static class ConnectionFactory{ | ||
public static IPointToInterlockingConnection CreateConnection<T> (IServiceProvider x) where T : IPointToInterlockingConnection { | ||
public class ConnectionFactory{ | ||
private IConfiguration _configuration { get; } | ||
private ILogger<ConnectionFactory> _logger { get; } | ||
|
||
public ConnectionFactory(ILogger<ConnectionFactory> logger, IConfiguration configuration){ | ||
_logger = logger; | ||
_configuration = configuration; | ||
} | ||
|
||
return ActivatorUtilities.CreateInstance<T>(x, CancellationToken.None); | ||
public IPointToInterlockingConnection CreateConnection(IServiceProvider x) { | ||
var connectionProtocol = _configuration.GetSection("ConnectionSettings").Get<PointConfiguration>()?.ConnectionProtocol; | ||
switch (connectionProtocol){ | ||
case ConnectionProtocol.EulynxBaseline4R1: | ||
return new EulynxBaseline4R1.PointToInterlockingConnection(x.GetRequiredService<ILogger<EulynxBaseline4R1.PointToInterlockingConnection>>(), _configuration, CancellationToken.None); | ||
case ConnectionProtocol.EulynxBaseline4R2: | ||
return new EulynxBaseline4R2.PointToInterlockingConnection(x.GetRequiredService<ILogger<EulynxBaseline4R2.PointToInterlockingConnection>>(), _configuration, CancellationToken.None); | ||
default: | ||
if (connectionProtocol != null) | ||
_logger.LogWarning($"Unknown connection protocol {connectionProtocol}. Using EulynxBaseline4R2."); | ||
else | ||
_logger.LogWarning($"No connection protocol specified. Using EulynxBaseline4R2."); | ||
return new EulynxBaseline4R2.PointToInterlockingConnection(x.GetRequiredService<ILogger<EulynxBaseline4R2.PointToInterlockingConnection>>(), _configuration, CancellationToken.None); | ||
} | ||
} | ||
} |
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