コード例 #1
0
        /// <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);
        }
コード例 #2
0
ファイル: AdapterBank.cs プロジェクト: yingted/Myro
 /// <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();
         }
     }
 }
コード例 #3
0
 public void Dispose()
 {
     OnReceive = delegate { };
     try
     {
         Adapter.Dispose();
         Device.Dispose();
     }
     catch
     {
     }
 }
コード例 #4
0
        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;
            }
        }
コード例 #5
0
        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;
        }
コード例 #6
0
 public void Dispose()
 {
     adapter?.Dispose();
 }
コード例 #7
0
ファイル: M3UFileReader.cs プロジェクト: colinshawn/M3U
 public void Dispose() => adapter?.Dispose();