FileSqlServerSync/Server/LocalServer/LocalSyncServerFactory.cs

40 lines
836 B
C#
Raw Normal View History

using Common;
2024-09-23 05:55:17 +00:00
using System.Net.WebSockets;
namespace LocalServer;
public class LocalSyncServerFactory
{
2024-07-31 09:14:07 +00:00
private readonly object Lock = new();
2024-09-23 05:55:17 +00:00
public void CreateLocalSyncServer(AbsPipeLine pipeLine, string name,AbsPipeLine absPipeLine)
{
2024-09-23 05:55:17 +00:00
var server = new LocalSyncServer(
pipeLine,
this,
name,
absPipeLine
);
2024-07-31 09:14:07 +00:00
lock (Lock)
{
Servers.Add(server);
}
}
private readonly List<LocalSyncServer> Servers = [];
public void RemoveLocalSyncServer(LocalSyncServer server)
{
2024-07-31 09:14:07 +00:00
lock (Lock)
{
Servers.Remove(server);
}
}
public LocalSyncServer? GetServerByName(string name)
{
2024-09-23 05:55:17 +00:00
var it = Servers.Where(x => x.Name == name).FirstOrDefault();
return it;
}
}