ServiceElementGetValueAsUri Method

Gets the value as a Uri.

Definition

Namespace: InTheHand.Net.Bluetooth.Sdp
Assembly: InTheHand.Net.Bluetooth (in InTheHand.Net.Bluetooth.dll) Version: 4.0.32+5cdf1cfd21064ea31c5de33d160200ca1c4bc218
C#
public Uri GetValueAsUri()

Return Value

Uri
The Url value as a Uri.

Remarks

It turns out that we can't trust vendors to add only valid URLs to their records, for instance the iPhone has an attribute with value "www.apple.com" which isn't a URL as it has no scheme part (http://) etc.

Thus a Url value in an element can be stored in a number of formats. If created by the parser then it will be stored as a String or as an array of Byte if property ServiceRecordParser.LazyUrlCreation is set. If created locally it can be those types or also Uri .

This method will try to convert from those formats to Uri. If the URL is invalid e.g. has bad characters or is missing the scheme part etc then an error will occur. One can instead access the element's Value property and expect one of the three types. When created by the parser it will be of type String unless LazyUrlCreation is set.

Exceptions

InvalidOperationException The service element is not of type ElementType.Url.

See Also