using System; namespace Mongo2Go.Helper { /// /// Intention: port numbers won't be assigned twice to avoid connection problems with integration tests /// public sealed class PortPool : IPortPool { private static readonly PortPool Instance = new PortPool(); // Explicit static constructor to tell C# compiler // not to mark type as beforefieldinit static PortPool() { } // Singleton private PortPool() { } public static PortPool GetInstance { get { return Instance; } } /// /// Returns and reserves a new port /// public int GetNextOpenPort() { IPortWatcher portWatcher = PortWatcherFactory.CreatePortWatcher(); return portWatcher.FindOpenPort(); } } }