FileSqlServerSync/Server/LocalServer/LocalSyncServerFactory.cs

32 lines
730 B
C#
Raw Normal View History

using System.Net.WebSockets;
using Common;
namespace LocalServer;
public class LocalSyncServerFactory
{
2024-07-31 09:14:07 +00:00
private readonly object Lock = new();
public void CreateLocalSyncServer(AbsPipeLine pipeLine, string name)
{
if (Servers.Select(x => x.Name == name).Any())
{
2024-09-05 01:59:57 +00:00
throw new Exception("LocalServer:存在同名发布源!");
}
var server = new LocalSyncServer(pipeLine, name, this);
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);
}
}
}