/// <summary> /// Decides if this pin can be connected to a target pin /// </summary> /// <param name="targetConnectorViewModel">Target pin's view model</param> /// <returns>True if successfull</returns> public override bool CanConnectTo(ConnectorViewModel targetConnectorViewModel) { var otherDataConnectorViewModel = targetConnectorViewModel as DataConnectorViewModel; // if the target is null or has the same parent as me if (otherDataConnectorViewModel == null || otherDataConnectorViewModel.Parent == this.Parent) { return(false); } if (this.PinDirection == PinDirectionDefinition.In && otherDataConnectorViewModel.PinDirection == PinDirectionDefinition.In || (this.PinDirection == PinDirectionDefinition.Out && otherDataConnectorViewModel.PinDirection == PinDirectionDefinition.Out)) { return(false); } if (DataConnectorType != null) { if (otherDataConnectorViewModel.DataConnectorType.IsAssignableFrom(DataConnectorType) || DataConnectorType == typeof(object)) { return(true); } } else { if (AllowedTypes.Contains(otherDataConnectorViewModel.DataConnectorType.Name)) { // call parent node to update connector types ParentViewModel.UpdateDataTypes(otherDataConnectorViewModel.DataConnectorType); return(true); } } return(false); }