private void Rec_DeviceFound(object sender, DeviceFoundEventArgs e) { if (e.Device == null) { return; } if (e.Device.Name == null) { return; } if (e.Device.BondState == Bond.Bonded | e.Device.BondState == Bond.Bonding) { return; } ListAdapter.Add(e.Device.Name); FoundDevices.Add(e.Device); }
/// <summary> /// Creates an adaptive load balancer with the function that scores the items in the list. /// </summary> /// <param name="scorer">the scoring function</param> /// <param name="items">the list of items to load balance (if null will create an empty list)</param> public UpdateableAdaptiveLoadBalancer(Func <T, int> scorer, IList <T> items = null) { adaptiveBalancer = new AdaptiveLoadBalancer <Updateable <T> >(Adapt(scorer)); Resources = new ListAdapter <T, Updateable <T> >( external => new Updateable <T>(external), intItem => intItem.Item, (extItem, intItem) => extItem.Equals(intItem.Item), adaptiveBalancer.Resources); if (items == null) { return; } foreach (var val in items) { Resources.Add(val); } }
public void Add() { _adapter.Add("5"); Assert.That(_innerList, Is.EqualTo(new[] { 1, 2, 3, 5 })); }