private static void SetRecordService(ServiceRecord m_record, Guid uuid128) { ServiceAttribute attr = m_record.GetAttributeById(UniversalAttributeId.ServiceClassIdList); ServiceElement element = (ServiceElement)attr.Value.GetValueAsElementList()[0]; element.SetValue(uuid128); }
private Guid GetRecordService(ServiceRecord m_record) { ServiceAttribute attr = m_record.GetAttributeById(UniversalAttributeId.ServiceClassIdList); ServiceElement element = (ServiceElement)attr.Value.GetValueAsElementList()[0]; Guid uuid128 = (Guid)element.Value; return(uuid128); }
/// <summary> /// Gets the attribute at the specified index. /// </summary> /// - /// <param name="index">The zero-based index of the attribute to get.</param> /// - /// <returns>A <see cref="T:InTheHand.Net.Bluetooth.ServiceAttribute"/> holding /// the attribute at the specified index. /// Is never <see langword="null"/>. /// </returns> /// - /// <exception cref="T:System.ArgumentOutOfRangeException"> /// <para>index is less than 0.</para> /// <para>-or-</para> /// <para>index is equal to or greater than Count. </para> /// </exception> public ServiceAttribute GetAttributeByIndex(Int32 index) { // The following will itself check the index to throw ArgumentOutOfRangeException. ServiceAttribute attr = (ServiceAttribute)m_attributes[index]; // cast for non-Generics build. System.Diagnostics.Debug.Assert(attr != null); return(attr); }
protected virtual void WriteAttribute(ServiceAttribute attr, byte[] buffer, ref int offset) { int len; len = CreateAttrId(attr.Id, buffer, offset); offset += len; len = CreateElement(attr.Value, buffer, offset); offset += len; }
/// <summary> /// Returns the attribute with the given ID and natural language. /// </summary> /// - /// <param name="id">The id of the service attribute to locate, as a /// <see cref="T:InTheHand.Net.Bluetooth.ServiceAttributeId"/>.</param> /// <param name="language"> /// Which multi-language version of the string attribute to locate. /// </param> /// - /// <returns>A <see cref="T:InTheHand.Net.Bluetooth.ServiceAttribute"/> holding /// the attribute with the specified ID and language. /// Is never <see langword="null"/>. /// </returns> /// - /// <exception cref="T:System.Collections.Generic.KeyNotFoundException"> /// There is no attribute with the given Id with the given language base in the record. /// </exception> public ServiceAttribute GetAttributeById(ServiceAttributeId id, LanguageBaseItem language) { if (language == null) { throw new ArgumentNullException("language"); } ServiceAttributeId actualId = CreateLanguageBasedAttributeId(id, language.AttributeIdBase); ServiceAttribute attr = GetAttributeById(actualId); System.Diagnostics.Debug.Assert(attr != null); return(attr); }
public String GetMultiLanguageStringAttributeById(ServiceAttributeId id, LanguageBaseItem language) { if (language == null) { throw new ArgumentNullException("language"); } ServiceAttributeId actualId = CreateLanguageBasedAttributeId(id, language.AttributeIdBase); ServiceAttribute attr = GetAttributeById(actualId); ServiceElement element = attr.Value; // (No need to check that element is of type TextString, that's handled inside the following). String str = element.GetValueAsString(language); return(str); }
//NODO No-(((TryGetAttributeById public? Also one with language param.))) private bool TryGetAttributeById(ServiceAttributeId id, out ServiceAttribute attribute) { foreach (ServiceAttribute curAttr in m_attributes) { if (curAttr.Id == id) { attribute = curAttr; System.Diagnostics.Debug.Assert(attribute != null); return(true); } }//for attribute = null; return(false); }
static ServiceElement GetChannelElement(ServiceRecord record, BluetoothProtocolDescriptorType proto) { if (!record.Contains(UniversalAttributeId.ProtocolDescriptorList)) { goto NotFound; } ServiceAttribute attr = record.GetAttributeById(UniversalAttributeId.ProtocolDescriptorList); #if !V1 bool?isSimpleRfcomm; #else object isSimpleRfcomm; #endif return(GetChannelElement(attr, proto, out isSimpleRfcomm)); NotFound: return(null); }
//-------------------------------------------------------------- /// <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); }
/// <overloads> /// Add a custom attribute. /// </overloads> /// - /// <summary> /// Add a custom attribute from a given <see cref="T:InTheHand.Net.Bluetooth.ServiceAttribute"/> /// </summary> /// - /// <param name="serviceAttribute">An attribute as a /// <see cref="T:InTheHand.Net.Bluetooth.ServiceAttribute"/> instance. /// </param> public void AddCustomAttribute(ServiceAttribute serviceAttribute) { this.AddCustomAttributes(new ServiceAttribute[] { serviceAttribute }); }
//NODO No-(((TryGetAttributeById public? Also one with language param.))) private bool TryGetAttributeById(ServiceAttributeId id, out ServiceAttribute attribute) { foreach (ServiceAttribute curAttr in m_attributes) { if (curAttr.Id == id) { attribute = curAttr; System.Diagnostics.Debug.Assert(attribute != null); return true; } }//for attribute = null; return false; }
// TODO GetRfcommChannelElement(ServiceAttribute attr) Could be public -> Tests! internal static ServiceElement GetChannelElement(ServiceAttribute attr, BluetoothProtocolDescriptorType proto, #if !V1 out bool?isSimpleRfcomm #else out object isSimpleRfcomm