How to check IConnectionService object for a valid connection?

Im connecting to Salesforce through the Salesforce Activities Package and are storing the connection in my IConnectionService object. But before i move on, I wish to check that the connection is valid. How do I do this?

This is what the object contains upon what i know is a valid connection:
SalesforceConnectionService { TelemetryService=TelemetryService { Enabled=false }, validConnection=true }

What i want to do is to check on the value of “validConnection”. But I cant figure out a way to check that property. I can check the TelemetryService { Enabled=false }, but this does not help me.

To anyone seeing this, I have not been able to solve this specific issue the way I wanted it to be solved. Nevertheless, I’ve implemented a workaround to this by sending a SOQL call to Salesforce after opening the connection and then checking the SalesforceStatus-object for Success=true or false. This is suboptimal, but seems to be working for the extent of this process.

If anyone ever finds a solution to the SalesforceConnectionService-object, feel free to share.

You can check the body of the variable where you store the connection. something like sfdcConnectionVar.ToString.Contains(“validConnection=true”)

This did not work. I believe it is not possible to convert an IConnectionService object to string by using .ToString.

Hi Fredrick,
Try to use connectionobject.connect which returns the boolean value if the connection is valid.
Thanks In Advance.