How to check whether a port acts as an Inport or an Outport in a bidirectional port

Hi,
I’d like to get something clarified.

I have a shape, I want to design a port that should support bidirectional connection, so I made both the Linkable.From and Linkable.To properties to True.

At any point, How do I get to know from the port object whether the port acts as an InPort or an OutPort for a connection?

If Link.ToPort == thatport then you know that port has that link coming into it.
If Link.FromPort == thatport then you know that port has that link coming out of it.
Note that both can be true at the same time, if your app allows it.
And of course you might have multiple links coming into a port and going out from it at the same time, if your app allows it.