public override IConnection Connect(IInputPlug inputPlug)
        {
            if (inputPlug is MethodPlug)
            {
                MethodPlug methodPlug = (MethodPlug)inputPlug;
                MethodInfo methodInfo = methodPlug.MethodInfo;

                Delegate connectionDelegate = null;

                try
                {
                    connectionDelegate = Delegate.CreateDelegate(eventInfo.EventHandlerType, inputPlug.Owner, methodInfo);
                    eventInfo.AddEventHandler(this.Owner, connectionDelegate);
                }
                catch (System.Exception)
                {
                    return(null);
                }

                // Create connection.
                EventMethodConnection connection = new EventMethodConnection(this, inputPlug, connectionDelegate);

                if (!inputPlug.OnConnection(connection))
                {
                    // Disconnect.
                    connection.Dispose();
                    return(null);
                }
                this.connections.Add(connection);
                return(connection);
            }
            return(null);
        }
        public override IConnection Connect(IInputPlug inputPlug)
        {
            if (inputPlug is MethodPlug)
            {
                MethodPlug methodPlug = (MethodPlug)inputPlug;
                MethodInfo methodInfo = methodPlug.MethodInfo;

                Delegate connectionDelegate = null;

                try
                {
                    connectionDelegate = Delegate.CreateDelegate(eventInfo.EventHandlerType, inputPlug.Owner, methodInfo);
                    eventInfo.AddEventHandler(this.Owner, connectionDelegate);
                }
                catch (System.Exception)
                {
                    return null;
                }

                // Create connection.
                EventMethodConnection connection = new EventMethodConnection(this,inputPlug,connectionDelegate);

                if (!inputPlug.OnConnection(connection))
                {
                    // Disconnect.
                    connection.Dispose();
                    return null;
                }
                this.connections.Add(connection);
                return connection;
            }
            return null;
        }