Exemplo n.º 1
0
        internal ConnectionPair(SimpleInMemConnection client, SimpleInMemConnection server)
        {
            if (server == null)
            {
                throw new ArgumentNullException(nameof(server));
            }
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }
            if (server.ConnectionType != ConnectionType.Server)
            {
                throw new ArgumentException($"{server.ToString()} - Invalid Server connection type: {server.ConnectionType}");
            }
            if (client.ConnectionType != ConnectionType.Client)
            {
                throw new ArgumentException($"{client.ToString()} - Invalid Client connection type: {client.ConnectionType}");
            }

            if (server.IsPaired)
            {
                throw new ArgumentException($"{server.ToString()} - already paired connection.");
            }

            if (client.IsPaired)
            {
                throw new ArgumentException($"{client.ToString()} - already paired connection.");
            }

            this.server = server;
            this.client = client;
        }