private static ServiceRecord CreateServiceRecord() { ServiceElement englishUtf8PrimaryLanguage = CreateEnglishUtf8PrimaryLanguageServiceElement(); ServiceRecord record = new ServiceRecord( new ServiceAttribute(InTheHand.Net.Bluetooth.AttributeIds.UniversalAttributeId.ServiceClassIdList, new ServiceElement(ElementType.ElementSequence, new ServiceElement(ElementType.Uuid16, (UInt16)0x1105))), new ServiceAttribute(InTheHand.Net.Bluetooth.AttributeIds.UniversalAttributeId.ProtocolDescriptorList, ServiceRecordHelper.CreateGoepProtocolDescriptorList()), #if ADD_SERVICE_NAME_TO_SDP_RECORD // Could add ServiceName, ProviderName etc here. new ServiceAttribute(InTheHand.Net.Bluetooth.AttributeIds.UniversalAttributeId.LanguageBaseAttributeIdList, englishUtf8PrimaryLanguage), new ServiceAttribute(ServiceRecord.CreateLanguageBasedAttributeId( InTheHand.Net.Bluetooth.AttributeIds.UniversalAttributeId.ProviderName, LanguageBaseItem.PrimaryLanguageBaseAttributeId), new ServiceElement(ElementType.TextString, "32feet.NET")), #endif // new ServiceAttribute(InTheHand.Net.Bluetooth.AttributeIds.ObexAttributeId.SupportedFormatsList, new ServiceElement(ElementType.ElementSequence, new ServiceElement(ElementType.UInt8, (byte)0xFF))) ); return(record); }
public void StringGivenString() { ushort LangCodeEn = 0x656e; // "en" ushort LangCodeIs = 0x6973; // "is" ushort EncodingIdUtf8 = 106; ushort EncodingIdUtf16BE = 1013; ushort BaseA = 0x0100; ushort BaseB = 0x0100; // String str = "ambds\u2022nbdas\u00FEdlka\U00012004slkda"; ServiceElement element_ = new ServiceElement(ElementType.TextString, str); ServiceAttributeId id = ServiceRecord.CreateLanguageBasedAttributeId(UniversalAttributeId.ServiceName, (ServiceAttributeId)BaseA); ServiceAttribute attribute = new ServiceAttribute(id, element_); ServiceRecord record = CreateRecord(attribute); // LanguageBaseItem langBaseEn = new LanguageBaseItem(LangCodeEn, EncodingIdUtf8, BaseA); LanguageBaseItem langBaseIs = new LanguageBaseItem(LangCodeIs, EncodingIdUtf16BE, BaseB); Assert.AreEqual(str, record.GetMultiLanguageStringAttributeById( InTheHand.Net.Bluetooth.AttributeIds.UniversalAttributeId.ServiceName, langBaseEn)); Assert.AreEqual(str, record.GetMultiLanguageStringAttributeById( InTheHand.Net.Bluetooth.AttributeIds.UniversalAttributeId.ServiceName, langBaseIs)); // ServiceElement element = record.GetAttributeById(UniversalAttributeId.ServiceName, langBaseIs).Value; Assert.AreEqual(ElementTypeDescriptor.TextString, element.ElementTypeDescriptor); Assert.AreEqual(ElementType.TextString, element.ElementType); Assert.IsInstanceOfType(typeof(String), element.Value); Assert.AreEqual(str, element.GetValueAsStringUtf8()); Assert.AreEqual(str, element.GetValueAsString(Encoding.ASCII)); Assert.AreEqual(str, element.GetValueAsString(Encoding.Unicode)); }
public ServiceRecord CreatePalmOsOppCompleteRecord() { List_ServiceAttribute attrs = new List_ServiceAttribute(); ServiceElement element; List_ServiceElement list; // attrs.Add(new ServiceAttribute(UniversalAttributeId.ServiceRecordHandle, new ServiceElement(ElementType.UInt32, (UInt32)0x10001))); // element = new ServiceElement(ElementType.Uuid16, (UInt16)0x1105); list = new List_ServiceElement(); list.Add(element); element = new ServiceElement(ElementType.ElementSequence, list); attrs.Add(new ServiceAttribute(UniversalAttributeId.ServiceClassIdList, element)); // element = ServiceRecordHelper.CreateGoepProtocolDescriptorList(); attrs.Add(new ServiceAttribute(UniversalAttributeId.ProtocolDescriptorList, element)); // const UInt16 Windows1252EncodingId = 2252; LanguageBaseItem[] languages = { new LanguageBaseItem("en", Windows1252EncodingId, LanguageBaseItem.PrimaryLanguageBaseAttributeId) }; element = LanguageBaseItem.CreateElementSequenceFromList(languages); attrs.Add(new ServiceAttribute(UniversalAttributeId.LanguageBaseAttributeIdList, element)); // // PalmOs really uses Windows-1252, but since the string is ASCII, UTF-8 is equivalent. element = new ServiceElement(ElementType.TextString, "OBEX Object Push"); attrs.Add(new ServiceAttribute( ServiceRecord.CreateLanguageBasedAttributeId(UniversalAttributeId.ServiceName, LanguageBaseItem.PrimaryLanguageBaseAttributeId), element)); // list = new List_ServiceElement(); list.Add(new ServiceElement(ElementType.UInt8, (byte)0x1)); list.Add(new ServiceElement(ElementType.UInt8, (byte)0x2)); list.Add(new ServiceElement(ElementType.UInt8, (byte)0x3)); list.Add(new ServiceElement(ElementType.UInt8, (byte)0xFF)); element = new ServiceElement(ElementType.ElementSequence, list); attrs.Add(new ServiceAttribute(ObexAttributeId.SupportedFormatsList, element)); // ServiceRecord record = new ServiceRecord(attrs); return(record); }
private static ServiceAttributeId DoTestNonExpected(ServiceAttributeId x, ServiceAttributeId y) { ServiceAttributeId result = ServiceRecord.CreateLanguageBasedAttributeId(x, y); return(result); }