ServiceRecordBuilder Class

Provides a simple way to build a ServiceRecord, including ServiceClassIds and ServiceNames attributes etc.

Definition

Namespace: InTheHand.Net.Bluetooth.Sdp
Assembly: InTheHand.Net.Bluetooth (in InTheHand.Net.Bluetooth.dll) Version: 4.0.32+5cdf1cfd21064ea31c5de33d160200ca1c4bc218
C#
public class ServiceRecordBuilder
Inheritance
Object    ServiceRecordBuilder

Remarks

The service’s Class Id can be set with the AddServiceClass(Guid)/AddServiceClass(UInt16)/etc methods, the protocol stack set with the ProtocolType property (default RFCOMM), and the Service Name set with the ServiceName property. Other properties and methods exist for controlling the more advanced attributes.

Adding the standard text-string attributes (ServiceName etc) is normally quite difficult due to the very baroque manner of specifying these strings’ character encoding and natural language. The builder handles all the complexity internally; the strings are written in UTF-8 encoding and marked as 'English' language.

Example

C#
ServiceRecordBuilder bldr = new ServiceRecordBuilder();
bldr.AddServiceClass(BluetoothService.SerialPort);
bldr.ServiceName = "Alan's SPP service";
//
ServiceRecord rcd = bldr.ServiceRecord;
C#
ServiceRecordBuilder bldr = new ServiceRecordBuilder();
bldr.ProtocolType = BluetoothProtocolDescriptorType.GeneralObex;
bldr.AddServiceClass(BluetoothService.ObexFileTransfer);
bldr.ServiceName = "Alan's FTP service";
//
ServiceRecord rcd = bldr.ServiceRecord;

Constructors

ServiceRecordBuilder Create a new instance of the ServiceRecordBuilder class.

Properties

ProtocolType Get or set which type of element will be added for the ProtocolDescriptorList attribute.
ProviderName Get or set a value for the ProviderName attribute.
ServiceDescription Get or set a value for the ServiceDescription attribute.
ServiceName Get or set a value for the ServiceName attribute.
ServiceRecord Gets the ServiceRecord instance constructed by the specified ServiceRecordBuilder instance.

Methods

AddBluetoothProfileDescriptor Add a BluetoothProfileDescriptorList element.
AddCustomAttribute(ServiceAttribute) Add a custom attribute from a given ServiceAttribute
AddCustomAttribute(ServiceAttributeId, ElementType, Object) Add a custom attribute of simple type.
AddCustomAttribute(UInt16, ElementType, Object) Add a custom attribute of simple type.
AddCustomAttributes(IEnumerable) Add a set of custom attribute.
AddCustomAttributes(IEnumerableServiceAttribute) Add a set of custom attribute.
AddCustomAttributes(ServiceAttribute) Add a set of custom attribute.
AddServiceClass(Guid) Add a Service Class Id.
AddServiceClass(Int32) Add a Service Class Id.
AddServiceClass(UInt16) Add a Service Class Id.
AddServiceClass(UInt32) Add a Service Class Id.
Equals
(Inherited from Object)
Finalize
(Inherited from Object)
FromJsr82ServerUri Converts a Java JSR 82 Bluetooth server URL into a ServiceRecordBuilder instance.
GetHashCode
(Inherited from Object)
GetType
(Inherited from Object)
MemberwiseClone
(Inherited from Object)
ToString
(Inherited from Object)

See Also