本文整理汇总了C#中IAdapter类的典型用法代码示例。如果您正苦于以下问题:C# IAdapter类的具体用法?C# IAdapter怎么用?C# IAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IAdapter类属于命名空间,在下文中一共展示了IAdapter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeviceListViewModel
public DeviceListViewModel(IDispatcherHelper dispatcherHelper,
INavigationService navigationService,
IAdapter adapter,
Func<IDevice, DeviceViewModel> deviceViewModelFactory)
{
_dispatcherHelper = dispatcherHelper;
_navigationService = navigationService;
_adapter = adapter;
_deviceViewModelFactory = deviceViewModelFactory;
_adapter.ScanTimeoutElapsed += (s, e) =>
{
StopScan();
};
_adapter.DeviceDiscovered += (s, e) =>
{
if (_devices.All(d => d.ID != e.Device.ID))
{
_dispatcherHelper.RunOnUIThread(() =>
{
_devices.Add(e.Device);
});
}
};
}
示例2: DockingViewManager
public DockingViewManager(ITransport transport, IAdapter adapter, IScheduler scheduler, LocalScheduler dispatcher)
{
_transport = transport;
_adapter = adapter;
_scheduler = scheduler;
_dispatcher = dispatcher;
}
示例3: DeviceList
public DeviceList (IAdapter adapter)
{
InitializeComponent ();
this.adapter = adapter;
this.devices = new ObservableCollection<IDevice> ();
listView.ItemsSource = devices;
adapter.DeviceDiscovered += (object sender, DeviceDiscoveredEventArgs e) => {
Device.BeginInvokeOnMainThread(() => {
devices.Add (e.Device);
});
};
adapter.ScanTimeoutElapsed += (sender, e) => {
adapter.StopScanningForDevices(); // not sure why it doesn't stop already, if the timeout elapses... or is this a fake timeout we made?
Device.BeginInvokeOnMainThread ( () => {
IsBusy = false;
DisplayAlert("Timeout", "Bluetooth scan timeout elapsed, no heart rate monitors were found", "OK");
});
};
ScanHrmButton.Activated += (sender, e) => {
InfoFrame.IsVisible = false;
// this is the UUID for Heart Rate Monitors
StartScanning (0x180D.UuidFromPartial());
};
}
示例4: DeviceList
public DeviceList (IAdapter adapter)
{
InitializeComponent ();
this.adapter = adapter;
this.devices = new ObservableCollection<IDevice> ();
listView.ItemsSource = devices;
adapter.DeviceDiscovered += (object sender, DeviceDiscoveredEventArgs e) => {
Device.BeginInvokeOnMainThread(() => {
devices.Add (e.Device);
});
};
adapter.ScanTimeoutElapsed += (sender, e) => {
IsBusy = false;
Debug.WriteLine ("Scan timeout");
if (autoScan) {
StartScanning ();
}
};
Appearing += (sender, e) => {
StartScanning();
};
}
示例5: DurationTraderViewModelController
public DurationTraderViewModelController(ITransport transport, IAdapter adapter, IScheduler scheduler, LocalScheduler dispatcher)
{
transport.GetTradingObservables()
.SubscribeOn(scheduler)
.ObserveOn(dispatcher)
.Subscribe(fSet => adapter.updater(fSet, ViewModel));
}
示例6: 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
};
}
示例7: SetAdapter
public void SetAdapter(IAdapter adapter)
{
if (this.adapter == adapter) return;
this.adapter = adapter;
if (adapter != null) adapter.RegisterDataSetObserver(richDataSetObsever);
ReloadChildViews();
}
示例8: TestPage
public TestPage (IAdapter adapter)
{
InitializeComponent ();
this.adapter = adapter;
this.devices = new ObservableCollection<IDevice> ();
this.services = new ObservableCollection<IService> ();
this.characteristics = new ObservableCollection<ICharacteristic> ();
adapter.BluetoothStateUpdated += Adapter_BluetoothStateUpdated;
adapter.ScanCompleted += Adapter_ScanCompleted;
adapter.DeviceDiscovered += Adapter_DeviceDiscovered;
adapter.DeviceConnected += Adapter_DeviceConnected;
adapter.DeviceDisconnected += Adapter_DeviceDisconnected;
adapter.DeviceFailedToConnect += Adapter_DeviceFailedToConnect;
adapter.CommandResponse += Adapter_CommandResponse;
btnValidate.Clicked += OnStartClicked;
btnGenerateCode.Clicked += OnGenerateCodeClicked;
btnDisconnect.Clicked += OnDisconnectDevice;
btnGenSerial.Clicked += OnGenSerialClicked;
btnValidateUser.Clicked += BtnValidateUser_Clicked;
btnChangeUser.Clicked += BtnChangeUser_Clicked;
//file.CreateFileAsync ("testFile.txt");
}
示例9: CharacteristicDetail_TISensor
public CharacteristicDetail_TISensor (IAdapter adapter, IDevice device, IService service, ICharacteristic characteristic)
{
InitializeComponent ();
this.characteristic = characteristic;
Title = characteristic.Name;
}
示例10: SetAdapter
public void SetAdapter(IAdapter adapter)
{
mIAdapter = adapter;
mIDevice.OnConnect(mIAdapter.controller);
}
示例11: Process
public bool Process(Data data, IAdapter adapter)
{
if (data.Device == device && (data.Service & service) > 0)
{
double value = Util.DataAdapter.GetGraphableValue(data);
if (comparison == "<")
{
if (value < threshold) Email(value, adapter);
}
else if (comparison == "<=")
{
if (value <= threshold) Email(value, adapter);
}
else if (comparison == "==")
{
if (value == threshold) Email(value, adapter);
}
else if (comparison == ">=")
{
if (value >= threshold) Email(value, adapter);
}
else if (comparison == ">")
{
if (value > threshold) Email(value, adapter);
}
}
return true;
}
示例12: DeviceList
public DeviceList (IAdapter adapter)
{
InitializeComponent ();
this.adapter = adapter;
this.devices = new ObservableCollection<IDevice> ();
listView.ItemsSource = devices;
adapter.DeviceDiscovered += (object sender, DeviceDiscoveredEventArgs e) => {
Device.BeginInvokeOnMainThread(() => {
//TODO: uncomment this if there are a lot of Bluetooth devices around cluttering your list (and remove the line below)
// if (e.Device.Name != null) {
// if (e.Device.Name.ToLower().Contains("biscuit")) {
// devices.Add(e.Device);
// }
// }
devices.Add (e.Device);
});
};
adapter.ScanTimeoutElapsed += (sender, e) => {
IsBusy = false;
Debug.WriteLine ("Scan timeout");
if (autoScan) {
StartScanning ();
}
};
Appearing += (sender, e) => {
StartScanning();
};
}
示例13: ConnectAsync
Task<ControlClient> ConnectAsync (IAdapter adapter)
{
var tcs = new TaskCompletionSource<ControlClient> ();
adapter.DeviceDiscovered += (object sender, DeviceDiscoveredEventArgs e) => {
Device.BeginInvokeOnMainThread(async () => {
// Look for a specific device
if (e.Device.ID.ToString ().StartsWith ("af18", StringComparison.OrdinalIgnoreCase)) {
// Connect to the device
await adapter.ConnectAsync (e.Device);
// Establish the control client
using (var stream = new LEStream (e.Device)) {
var client = new ControlClient (stream);
client.RunAsync (CancellationToken.None); // Don't await to run in background
tcs.SetResult (client);
}
// Update the UI
connectLabel.Text = "Yay " + e.Device + "!";
}
});
};
adapter.StartScanningForDevices();
return tcs.Task;
}
示例14: PrintUserInfo
public static void PrintUserInfo(IAdapter adapter)
{
Console.WriteLine("Имя:\t\t\t {0}", adapter.Name);
Console.WriteLine("Возраст:\t\t {0}", adapter.Age);
Console.WriteLine("Количество друзей:\t {0}", adapter.NumberOfFriends);
Console.WriteLine("------- -------- ------- -------");
}
示例15: RequestResourceContext
public RequestResourceContext(IAdapter adapter, IAdaptee adaptee,
RequestType resource)
{
Adaptee = adaptee;
Adapter = adapter;
ReqType = resource;
}