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 (IsCompatible(inputPlug)) { if (property.CurrentValue == null) { InterfacePlug plug = (InterfacePlug)inputPlug; property.CurrentValue = plug.Owner.QueryInterface(plug.InterfaceType); PropertyInterfaceConnection connection = new PropertyInterfaceConnection(this, inputPlug); if (!inputPlug.OnConnection(connection)) { connection.Dispose(); return null; } this.connections.Add(connection); return connection; } } return null; }
public override IConnection Connect(IInputPlug inputPlug) { if (IsCompatible(inputPlug)) { if (property.CurrentValue == null) { InterfacePlug plug = (InterfacePlug)inputPlug; property.CurrentValue = plug.Owner.QueryInterface(plug.InterfaceType); PropertyInterfaceConnection connection = new PropertyInterfaceConnection(this, inputPlug); if (!inputPlug.OnConnection(connection)) { 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; }