本文整理汇总了C#中IDevice.DiscoverServices方法的典型用法代码示例。如果您正苦于以下问题:C# IDevice.DiscoverServices方法的具体用法?C# IDevice.DiscoverServices怎么用?C# IDevice.DiscoverServices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDevice
的用法示例。
在下文中一共展示了IDevice.DiscoverServices方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ServiceList
public ServiceList (IAdapter adapter, IDevice device)
{
InitializeComponent ();
this.adapter = adapter;
this.device = device;
this.services = new ObservableCollection<IService> ();
listView.ItemsSource = services;
// when device is connected
adapter.DeviceConnected += (s, e) => {
device = e.Device; // do we need to overwrite this?
// when services are discovered
device.ServicesDiscovered += (object se, EventArgs ea) => {
Debug.WriteLine("device.ServicesDiscovered");
//services = (List<IService>)device.Services;
if (services.Count == 0)
Device.BeginInvokeOnMainThread(() => {
foreach (var service in device.Services) {
services.Add(service);
}
});
};
// start looking for services
device.DiscoverServices ();
};
// TODO: add to IAdapter first
//adapter.DeviceFailedToConnect += (sender, else) => {};
DisconnectButton.Activated += (sender, e) => {
adapter.DisconnectDevice (device);
Navigation.PopToRootAsync(); // disconnect means start over
};
}
示例2: DevicePage
public DevicePage(IDevice device)
{
_device = device;
_device.ServiceDiscovered += ServiceDiscovered;
DiscoveredServices = new ObservableCollection<Grouping<IService, ICharacteristic>>();
InitializeComponent();
BindingContext = _device;
serviceListView.ItemsSource = DiscoveredServices;
serviceListView.ItemSelected += ServiceSelected;
App.BluetoothAdapter.DeviceDisconnected += DeviceDisconnected;
_device.DiscoverServices();
}
示例3: Adapter_DeviceConnected
void Adapter_DeviceConnected (object sender, DeviceConnectionEventArgs e)
{
Debug.WriteLine("Device connected");
//adapter.StopScanningForDevices();
StopScanning();
Device.BeginInvokeOnMainThread(() => {
this.lblConnectedDevice.IsVisible = true;
this.btnGenerateCode.IsVisible = true;
this.btnDisconnect.IsVisible = true;
this.lblConnectedDevice.Text = "Device Connected: " + e.Device.Name;
});
Debug.WriteLine("Connected Devices Count: "+ adapter.ConnectedDevices.Count);
device = e.Device;
device.ServicesDiscovered += Device_ServicesDiscovered;
device.DiscoverServices ();
}