コード例 #1
0
ファイル: CoverArgException.cs プロジェクト: zhubin-12/32feet
        public void AttributeIdLookup_NullType()
        {
            LanguageBaseItem langBase;

            AttributeIdLookup.GetName(UniversalAttributeId.ProtocolDescriptorList,
                                      null, new LanguageBaseItem[0], out langBase);
        }
コード例 #2
0
ファイル: AttrIdLookupTests.cs プロジェクト: zhubin-12/32feet
        public void OneSimple()
        {
            String name = AttributeIdLookup.GetName((ServiceAttributeId)0x0001,
                                                    new Type[] { typeof(UniversalAttributeId) });

            Assert.AreEqual("ServiceClassIdList", name);
        }
コード例 #3
0
ファイル: CoverArgException.cs プロジェクト: zhubin-12/32feet
        public void AttributeIdLookup_NullLangBaseList()
        {
            LanguageBaseItem langBase;

            AttributeIdLookup.GetName(UniversalAttributeId.ProtocolDescriptorList,
                                      new Type[] { typeof(UniversalAttributeId) },
                                      null, out langBase);
        }
コード例 #4
0
ファイル: AttrIdLookupTests.cs プロジェクト: zhubin-12/32feet
        public void TwoSimple()
        {
            String name = AttributeIdLookup.GetName((ServiceAttributeId)0x0302,
                                                    new Type[] {
                typeof(UniversalAttributeId),
                typeof(HeadsetProfileAttributeId)
            });

            Assert.AreEqual("RemoteAudioVolumeControl", name);
        }
コード例 #5
0
        /// <summary>
        /// Produce a 'dump' of the given record, including attribute names etc to the given
        /// <see cref="T:System.IO.TextWriter"/>.
        /// </summary>
        /// -
        /// <remarks>
        /// <para>The system has built-in a set of mappings from Service Class to
        /// its Attribute IDs. This is supplied by the
        /// <see cref="T:InTheHand.Net.Bluetooth.MapServiceClassToAttributeIdList"/> class,
        /// and contains the Attribute IDs defined in the base SDP specification as
        /// well as in Bluetooth Profiles specification e.g. ObjectPushProfile, Headset,
        /// Panu, etc.
        /// If however the record being decoded is a custom one then a set of extra
        /// Attribute Id definitions can be supplied in the
        /// <paramref name="attributeIdEnumDefiningTypes"/> parameter.
        /// The Attribute IDs for a particular Service Class
        /// should be defined in a static class and the set of such classes should
        /// be passed as their <see cref="T:System.Type"/> object. e.g.
        /// <code lang="C#">
        /// static class FooAttributeId
        /// {
        ///     public const ServiceAttributeId BarName = (ServiceAttributeId)0x0300;
        /// }
        ///
        /// &#x2026;
        ///     ServiceRecordUtilities.Dump(writer, myRecord, typeof(FooAttributeId));
        /// &#x2026;
        /// </code>
        /// </para>
        /// </remarks>
        /// -
        /// <param name="writer">A <see cref="T:System.IO.TextWriter"/> where the 'dump'
        /// text is to be written.</param>
        /// <param name="record">A <see cref="T:InTheHand.Net.Bluetooth.ServiceRecord"/> to be dumped.</param>
        /// <param name="attributeIdEnumDefiningTypes">
        /// An optional array of <see cref="T:System.Type"/> specifing a set of Ids
        /// for the attributes contained in this record.  See the
        /// </param>
        /// <seealso cref="M:InTheHand.Net.Bluetooth.ServiceRecordUtilities.Dump(InTheHand.Net.Bluetooth.ServiceRecord,System.Type[])"/>
        public static void Dump(TextWriter writer, ServiceRecord record, params Type[] attributeIdEnumDefiningTypes)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (record == null)
            {
                throw new ArgumentNullException("record");
            }
            //
            // ....
            // Get the AttributeIdEnumDefiningType for the services contained in the record.
            Type[] recordSpecificAttributeIdEnumDefiningTypes = GetServiceClassSpecificAttributeIdEnumDefiningType(record);
            //
            // Prepend the Universal Attribute Id definition class to the supplied list.
            Type[] allAttributeIdEnumDefiningTypes;
            allAttributeIdEnumDefiningTypes = CombineAttributeIdEnumDefiningTypes(attributeIdEnumDefiningTypes, recordSpecificAttributeIdEnumDefiningTypes);
            //
            LanguageBaseItem[] langBaseList = record.GetLanguageBaseList();
            //
            bool firstAttr = true;

            foreach (ServiceAttribute attr in record)
            {
                if (!firstAttr)
                {
                    writer.WriteLine();
                }
                ServiceAttributeId id = attr.Id;
                LanguageBaseItem   applicableLangBase;
                string             name = AttributeIdLookup.GetName(id, allAttributeIdEnumDefiningTypes, langBaseList, out applicableLangBase);
                if (name == null)
                {
                    writer.WriteLine("AttrId: 0x{0:X4}", unchecked ((ushort)attr.Id));
                }
                else
                {
                    writer.WriteLine("AttrId: 0x{0:X4} -- {1}", (ushort)attr.Id, name);
                }
                //----
                if (attr.Value.ElementType == ElementType.TextString)
                {
                    DumpString(writer, 0, attr.Value, applicableLangBase);
                }
                else
                {
                    DumpElement(writer, 0, attr.Value);
                }
                // Now print descriptive information for some cases.
                // e.g. for PDL: "( ( L2Cap ), ( Rfcomm, ChannelNumber=1 ), ( Obex ) )"
                if (id == AttributeIds.UniversalAttributeId.ProtocolDescriptorList)
                {
                    DumpProtocolDescriptorList(writer, 0, attr.Value);
                }
                if (id == AttributeIds.UniversalAttributeId.AdditionalProtocolDescriptorLists)
                {
                    DumpAdditionalProtocolDescriptorLists(writer, 0, attr.Value);
                }
                //TODO (( DumpLanguageBaseAttributeIdList, use ParseListFromElementSequence ))
                firstAttr = false;
            }//for
        }