Пример #1
0
 public IOBluetoothDeviceSearchAttributes(
     IOBluetoothDeviceSearchOptions options = IOBluetoothDeviceSearchOptions.None,
     uint maxResults = 0,
     IOBluetoothDeviceSearchDeviceAttributes[] attributes = null)
 {
     this.options    = options;
     this.maxResults = maxResults;
     if (attributes == null)
     {
         this.deviceAttributeCount = 0;
         this.attributeList        = IntPtr.Zero;
     }
     else
     {
         this.deviceAttributeCount = (uint)attributes.Length;
         int attributeSize = Marshal.SizeOf(typeof(IOBluetoothDeviceSearchDeviceAttributes));
         var pos           = this.attributeList = Marshal.AllocHGlobal(attributeSize * attributes.Length);
         foreach (var item in attributes)
         {
             Marshal.StructureToPtr(item, pos, false);
             pos += attributeSize;
         }
     }
 }
Пример #2
0
		public IOBluetoothDeviceSearchAttributes (
			IOBluetoothDeviceSearchOptions options = IOBluetoothDeviceSearchOptions.None,
			uint maxResults = 0,
			IOBluetoothDeviceSearchDeviceAttributes[] attributes = null)
		{
			this.options = options;
			this.maxResults = maxResults;
			if (attributes == null) {
				this.deviceAttributeCount = 0;
				this.attributeList = IntPtr.Zero;
			} else {
				this.deviceAttributeCount = (uint)attributes.Length;
				int attributeSize = Marshal.SizeOf (typeof(IOBluetoothDeviceSearchDeviceAttributes));
				var pos = this.attributeList = Marshal.AllocHGlobal (attributeSize * attributes.Length);
				foreach (var item in attributes) {
					Marshal.StructureToPtr (item, pos, false);
					pos += attributeSize;
				}
			}
		}