public void OneItem()
 {
     LanguageBaseItem[] items = LanguageBaseItem.ParseListFromElementSequence(Data_LanguageBaseList.AttrOneItem.Value);
     Assert.AreEqual(1, items.Length);
     Assert.AreEqual(Data_LanguageBaseList.LangStringEn, items[0].NaturalLanguage, "NaturalLanguage");
     Assert.AreEqual(Data_LanguageBaseList.LangEn, items[0].NaturalLanguageAsUInt16, "NaturalLanguageUInt16");
     Assert.AreEqual(Data_LanguageBaseList.EncUtf8, items[0].EncodingId, "EncodingId");
     Assert.AreEqual(Data_LanguageBaseList.EncUtf8, items[0].EncodingIdAsInt16, "EncodingId");
     Assert.AreEqual((ServiceAttributeId)0x0100, items[0].AttributeIdBase, "AttributeIdBase");
 }
 public void TwoItems()
 {
     LanguageBaseItem[] items = LanguageBaseItem.ParseListFromElementSequence(Data_LanguageBaseList.AttrTwoItems.Value);
     Assert.AreEqual(2, items.Length);
     Assert.AreEqual(Data_LanguageBaseList.LangStringEn, items[0].NaturalLanguage, "NaturalLanguage");
     Assert.AreEqual(Data_LanguageBaseList.LangEn, items[0].NaturalLanguageAsUInt16, "NaturalLanguageUInt16");
     Assert.AreEqual(Data_LanguageBaseList.EncUtf8, items[0].EncodingId, "EncodingId");
     Assert.AreEqual((ServiceAttributeId)0x0100, items[0].AttributeIdBase, "AttributeIdBase");
     //
     Assert.AreEqual(Data_LanguageBaseList.LangStringFr, items[1].NaturalLanguage, "NaturalLanguage");
     Assert.AreEqual(Data_LanguageBaseList.LangFr, items[1].NaturalLanguageAsUInt16, "NaturalLanguageUInt16");
     Assert.AreEqual(Data_LanguageBaseList.EncWindows1252, items[1].EncodingId, "EncodingId");
     Assert.AreEqual((ServiceAttributeId)0x0110, items[1].AttributeIdBase, "AttributeIdBase");
 }
Beispiel #3
0
        //--------------------------------------------------------------

        /// <summary>
        /// Gets the list of LanguageBaseAttributeId items in the service record.
        /// </summary>
        /// -
        /// <remarks>
        /// See also <see cref="M:InTheHand.Net.Bluetooth.ServiceRecord.GetPrimaryLanguageBaseItem"/>.
        /// </remarks>
        /// -
        /// <returns>
        /// An array of <see cref="T:InTheHand.Net.Bluetooth.LanguageBaseItem"/>.
        /// An array of length zero is returned if the service record contains no such attribute.
        /// </returns>
        /// -
        /// <seealso cref="M:InTheHand.Net.Bluetooth.ServiceRecord.GetPrimaryLanguageBaseItem"/>
        public LanguageBaseItem[] GetLanguageBaseList()
        {
            if (!Contains(InTheHand.Net.Bluetooth.AttributeIds.UniversalAttributeId.LanguageBaseAttributeIdList))
            {
                return(new LanguageBaseItem[0]);
            }
            ServiceAttribute attr = GetAttributeById(InTheHand.Net.Bluetooth.AttributeIds.UniversalAttributeId.LanguageBaseAttributeIdList);

            if (attr.Value.ElementType != ElementType.ElementSequence)
            {
                return(new LanguageBaseItem[0]);
            }
            LanguageBaseItem[] langList;
            try {
                langList = LanguageBaseItem.ParseListFromElementSequence(attr.Value);
            } catch (System.Net.ProtocolViolationException) {
                return(new LanguageBaseItem[0]);
            }
            return(langList);
        }
 public void OneItemBadNotSeq()
 {
     LanguageBaseItem[] items = LanguageBaseItem.ParseListFromElementSequence(Data_LanguageBaseList.AttrOneItemBadNotSeq.Value);
 }
 public void FourElements()
 {
     LanguageBaseItem[] items = LanguageBaseItem.ParseListFromElementSequence(Data_LanguageBaseList.AttrFourElements.Value);
 }