public Connection Connect(Socket otherSocket, Guid guid) { if (Type == SocketType.Input && otherSocket is SocketIn) { throw new ArgumentException(); } if (Type == SocketType.Output && otherSocket is SocketOut) { throw new ArgumentException(); } if (!NodeUtils.CanConnect(this, otherSocket)) { throw new ArgumentException(); } Connection = null; var @in = Type == SocketType.Input ? (SocketIn)this : (SocketIn)otherSocket; var @out = Type == SocketType.Output ? (SocketOut)this : (SocketOut)otherSocket; Connection = new Connection(guid, @in, @out); otherSocket.Connection = Connection; Connection.In.ResetValue(); Connection.Out.ResetValue(); return(Connection); }