Viewer to Server
This commit is contained in:
36
Server/Repositories/ClientSettingsRepository.cs
Normal file
36
Server/Repositories/ClientSettingsRepository.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using OI.Metrology.Server.Models;
|
||||
using OI.Metrology.Shared.Models.Stateless;
|
||||
using System.Net;
|
||||
|
||||
namespace OI.Metrology.Server.Repository;
|
||||
|
||||
public class ClientSettingsRepository : IClientSettingsRepository
|
||||
{
|
||||
|
||||
private readonly AppSettings _AppSettings;
|
||||
|
||||
public ClientSettingsRepository(AppSettings appSettings) => _AppSettings = appSettings;
|
||||
|
||||
internal List<string> GetClientSettings(IPAddress? remoteIpAddress)
|
||||
{
|
||||
List<string> results = new();
|
||||
if (remoteIpAddress is null)
|
||||
results.Add(nameof(remoteIpAddress));
|
||||
else
|
||||
results.Add(remoteIpAddress.ToString());
|
||||
if (!_AppSettings.IsDevelopment)
|
||||
throw new Exception("Shouldn't expose!");
|
||||
return results;
|
||||
}
|
||||
|
||||
List<string> IClientSettingsRepository.GetClientSettings(IPAddress? remoteIpAddress) => GetClientSettings(remoteIpAddress);
|
||||
|
||||
internal static string GetIpAddress(IPAddress? remoteIpAddress)
|
||||
{
|
||||
string result = remoteIpAddress is null ? string.Empty : remoteIpAddress.ToString();
|
||||
return result;
|
||||
}
|
||||
|
||||
string IClientSettingsRepository.GetIpAddress(IPAddress? remoteIpAddress) => GetIpAddress(remoteIpAddress);
|
||||
|
||||
}
|
Reference in New Issue
Block a user