Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AF SDK Reference

AFConnections.IsValidConnection Method (Boolean, Boolean, AFElementTemplate, AFPort, AFElementTemplate, AFPort, String)

AFConnections.IsValidConnection Method (Boolean, Boolean, AFElementTemplate, AFPort, AFElementTemplate, AFPort, String)

  • Last UpdatedNov 18, 2025
  • 3 minute read
AFConnections.IsValidConnection Method (Boolean, Boolean, AFElementTemplate, AFPort, AFElementTemplate, AFPort, String)
This method checks if a valid connection can be created between the specified source and destination ports of an AFElementTemplate or AFBaseElement.

Namespace:  OSIsoft.AF.Modeling
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182

Syntax

public bool IsValidConnection(
	bool checkSourceMaxConnections,
	bool checkDestinationMaxConnections,
	AFElementTemplate sourceTemplate,
	AFPort sourcePort,
	AFElementTemplate destinationTemplate,
	AFPort destinationPort,
	out string errMsg
)
Public Function IsValidConnection ( 
	checkSourceMaxConnections As Boolean,
	checkDestinationMaxConnections As Boolean,
	sourceTemplate As AFElementTemplate,
	sourcePort As AFPort,
	destinationTemplate As AFElementTemplate,
	destinationPort As AFPort,
	<OutAttribute> ByRef errMsg As String
) As Boolean

Dim instance As AFConnections
Dim checkSourceMaxConnections As Boolean
Dim checkDestinationMaxConnections As Boolean
Dim sourceTemplate As AFElementTemplate
Dim sourcePort As AFPort
Dim destinationTemplate As AFElementTemplate
Dim destinationPort As AFPort
Dim errMsg As String
Dim returnValue As Boolean

returnValue = instance.IsValidConnection(checkSourceMaxConnections, 
	checkDestinationMaxConnections, 
	sourceTemplate, sourcePort, destinationTemplate, 
	destinationPort, errMsg)
public:
bool IsValidConnection(
	bool checkSourceMaxConnections, 
	bool checkDestinationMaxConnections, 
	AFElementTemplate^ sourceTemplate, 
	AFPort^ sourcePort, 
	AFElementTemplate^ destinationTemplate, 
	AFPort^ destinationPort, 
	[OutAttribute] String^% errMsg
)
member IsValidConnection : 
        checkSourceMaxConnections : bool * 
        checkDestinationMaxConnections : bool * 
        sourceTemplate : AFElementTemplate * 
        sourcePort : AFPort * 
        destinationTemplate : AFElementTemplate * 
        destinationPort : AFPort * 
        errMsg : string byref -> bool 

Parameters

checkSourceMaxConnections
Type: SystemBoolean
If , check the source port to determine if the maximum number of connections will be exceeded. If , this check will not be performed. You would not want to perform this check if you are attempting to check if the destination could be changed to a different port before removing the current connection. Normally this parameter should be set to .
checkDestinationMaxConnections
Type: SystemBoolean
If , check the destination port to determine if the maximum number of connections will be exceeded. If , this check will not be performed. You would not want to perform this check if you are attempting to check if the source could be changed to a different port before removing the current connection. Normally this parameter should be set to .
sourceTemplate
Type: OSIsoft.AF.AssetAFElementTemplate
The source AFElementTemplate object for the specified sourcePort parameter if the port is from a template. If the port is from a AFBaseElement, then this parameter should be .
sourcePort
Type: OSIsoft.AF.ModelingAFPort
The source AFPort object of the connection. The port type must be either Output or Undirected. If the port is from an AFElementTemplate, then the sourceTemplate parameter must be specified.
destinationTemplate
Type: OSIsoft.AF.AssetAFElementTemplate
The destination AFElementTemplate object for the specified destinationPort parameter if the port is from a template. If the port is from a AFBaseElement, then this parameter should be .
destinationPort
Type: OSIsoft.AF.ModelingAFPort
The destination AFPort object of the connection. The port type must be either Input or Undirected. If the port is from an AFElementTemplate, then the destinationTemplate parameter must be specified.
errMsg
Type: SystemString
The returned error message if the connection is invalid.

Return Value

Type: Boolean
Returns if the connection is valid. If the connection is invalid, returns and the errMsg parameter specifies the error message.

Exceptions

ExceptionCondition
ArgumentNullException This exception is thrown when the sourcePort parameter or the destinationPort parameter is .

Version Information

AFSDK


See Also

In This Topic
TitleResults for “How to create a CRG?”Also Available in