In The Hand - .NET Components for Mobility
ServiceElement Class
NamespacesInTheHand.Net.BluetoothServiceElement
Holds an SDP data element.
Declaration Syntax
C#Visual Basic
public class ServiceElement
Public Class ServiceElement
Members
All MembersConstructorsMethodsProperties



IconMemberDescription
ServiceElement(ElementType, Object)
Initializes a new instance of the ServiceElement class.

ServiceElement(ElementType, IList<(Of <(ServiceElement>)>))
Initializes a new instance of the ServiceElement class.

ServiceElement(ElementType, array<ServiceElement>[]()[])
Initializes a new instance of the ServiceElement class.

CreateNumericalServiceElement(ElementType, Object)
Create an instance of ServiceElement but internally converting the numeric value to the required type.

ElementType
Gets the type of the element as an ElementType.

ElementTypeDescriptor
Gets the SDP Element Type Descriptor of the element as an ElementTypeDescriptor.

Equals(Object)
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Finalize()()()
Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
(Inherited from Object.)
GetHashCode()()()
Serves as a hash function for a particular type. GetHashCode()()() is suitable for use in hashing algorithms and data structures like a hash table.
(Inherited from Object.)
GetType()()()
Gets the Type of the current instance.
(Inherited from Object.)
GetValueAsElementArray()()()
Gets the value as a array of ServiceElement.

GetValueAsElementList()()()
Gets the value as a list of ServiceElement.

GetValueAsString(Encoding)
Get the value of the TextString, where it is encoded using the given encoding form.

GetValueAsString(LanguageBaseItem)
Get the value of the TextString, when it is encoded as specified by the given IETF Charset identifer.

GetValueAsStringUtf8()()()
Get the value of the TextString, when it is encoded as UTF-8.

GetValueAsUri()()()
Gets the value as a Uri.

GetValueAsUuid()()()
Gets the value as a Guid.

MemberwiseClone()()()
Creates a shallow copy of the current Object.
(Inherited from Object.)
ToString()()()
Returns a String that represents the current Object.
(Inherited from Object.)
Value
Gets the value of the element as the .NET type it is stored as.

Remarks

A Service Element hold the data in a SDP Service Record. It can hold various types of data, being like the ‘variant’ type in some environments. Each ServiceAttribute in a ServiceRecord holds its content in a Service Element.

The types currently defined in the Service Discovery specification include unsigned and signed integers of various sizes (8-bit, 16-bit etc), UUIDs in the full 128-bit form or in the 16 and 32-bit forms, TextString, Url etc. An element can itself also contain a list of element, either as a ‘sequence’ or an ‘alternative’, and thus an attribute can contain a tree of values, e.g. as used by the ProtocolDescriptorList attribute.

The type that an element is holding can be accessed with the ElementTypeDescriptor and ElementType properties which are of type ElementTypeDescriptor and ElementType respectively, the former being the ‘major’ type e.g. UnsignedInteger, and the latter the ‘minor’ type e.g. UInt16.

The element's value can be accessed in various ways, either directly in its internal form through its Value property. It has return type Object so the value will have to be cast before use, see the UInt16 example below. There are also a number of type-specific methods, e.g. GetValueAsElementArray()()(), GetValueAsUuid()()(), GetValueAsString(Encoding) etc. Each will throw an InvalidOperationException if the element is not of a suitable type. The complete set is:

ElementTypeAccess method, or .NET Type for direct access
Nil
nullNothingnullptr
Uint8
Byte
Uint16
UInt16
Uint32
UInt32
Uint64
Currently unsupported.
Uint128
Currently unsupported.
Int8
SByte
Int16
Int16
Int32
Int32
Int64
Currently unsupported.
Int128
Currently unsupported.
Uuid16
Via GetValueAsUuid()()(), or as UInt16
Uuid32
Via GetValueAsUuid()()(), or as UInt16
Uuid128
Via GetValueAsUuid()()()
TextString
With GetValueAsString(Encoding) or GetValueAsStringUtf8()()() etc. The underlying value can be an array of bytes, or as a String the ServiceRecordParser will set an array of bytes, whereas a manually created record will likely contain a String.
Boolean
Boolean
ElementSequence
With GetValueAsElementArray()()() or GetValueAsElementList()()()
ElementSequence
-"-
Url
Via GetValueAsUri()()(), can be stored interally as Uri or as an array of bytes

Note that there are no access methods for the numeric type for instance so the Value property will have to be used e.g.

CopyC#
// ElementType is UInt16
ushort x = (ushort)element.Value;
or
CopyC#
// ElementType is UInt16
Dim x As UShort = CUShort(element.Value);

Additional type-specific methods can be added as required, in fact the full set of 19+ could be added, it just requires implementation and test…

Inheritance Hierarchy
Object
ServiceElement

Assembly: InTheHand.Net.Personal (Module: InTheHand.Net.Personal) Version: 2.2.0.0