/// <summary> /// Adds a new adapter to the access. /// </summary> /// <param name="adapter"></param> public void AddAdapter(MAdapterDescription description, MMIAdapter.Iface adapter) { IAdapter newAdapter = new LocalAdapterAccess(description, adapter, this); //Check if the adapter is already available as a remote one if (this.Adapters.Exists(s => s.Description.Name == description.Name && description.Addresses[0] == description.Addresses[0] && s.Description.Addresses[0].Port == description.Addresses[0].Port)) { //Find the old adapter IAdapter oldAdapter = this.Adapters.Find(s => s.Description.Name == description.Name && description.Addresses[0] == description.Addresses[0] && s.Description.Addresses[0].Port == description.Addresses[0].Port); //Find MMUs which utilize the old adapter List <Abstraction.MotionModelUnitAccess> mmusWithOldAdapter = this.MotionModelUnits.Where(s => ((Abstraction.MotionModelUnitAccess)s).Adapter == oldAdapter).Select(s => ((Abstraction.MotionModelUnitAccess)s)).ToList(); //Change the adapter to the new one foreach (Abstraction.MotionModelUnitAccess mmu in mmusWithOldAdapter) { mmu.ChangeAdapter(newAdapter); } //Disposes the adapter oldAdapter.Dispose(); //Remove the old adapter this.Adapters.Remove(oldAdapter); } //Add the new adapter this.Adapters.Add(newAdapter); }
/// <summary> /// You must call this method on exiting. It disposes each /// adapter. /// </summary> public void Dispose() { foreach (var a in adapterNames.Values) { IAdapter adapter = a.AdapterIfAttached; if (adapter != null) { adapter.Dispose(); } } }
public void Dispose() { OnReceive = delegate { }; try { Adapter.Dispose(); Device.Dispose(); } catch { } }
private void UnhookCityModel() { CanvasView personsView = FindViewById <CanvasView>(Resource.Id.personsView); if (personsView.Adapter != null) { IAdapter personsViewAdapter = personsView.Adapter; personsView.Adapter = null; personsViewAdapter.Dispose(); } if (_cityModel != null) { _cityModel.PersonsRequestFailed -= CityModel_PersonsRequestFailed; _cityModel.AuthenticationFailed -= CityModel_AuthenticationFailed; } }
private void UnhookModel() { UnhookCityModel(); AutoCompleteTextView changeCityTextView = FindViewById <AutoCompleteTextView>(Resource.Id.changeCityTextView); if (changeCityTextView.Adapter != null) { IAdapter changeCityAdapter = changeCityTextView.Adapter; changeCityTextView.Adapter = null; changeCityAdapter.Dispose(); } if (_interactionModel != null) { _interactionModel.CurrentProfileChanged -= InteractionModel_CurrentProfileChanged; _interactionModel.CurrentCityChanged -= InteractionModel_CurrentCityChanged; } Button registerButton = FindViewById <Button>(Resource.Id.registerButton); registerButton.Click -= RegisterButton_Click; }
public void Dispose() { adapter?.Dispose(); }
public void Dispose() => adapter?.Dispose();