1- using System ;
1+ using System ;
22using System . Collections . Generic ;
3- using System . Linq ;
4- using System . Reflection ;
53using System . Runtime . CompilerServices ;
6- using System . Text ;
7- using System . Threading ;
8- using System . Threading . Tasks ;
94using System . Windows . Controls ;
105using NLog ;
11- using NLog . Fluent ;
126using Torch . API ;
137using Torch . Collections ;
8+ using Torch . Collections . Concurrent ;
149using Torch . Managers ;
1510using Torch . Server . ViewModels . Entities ;
1611using Torch . Utils ;
@@ -87,8 +82,8 @@ protected override EntityControlViewModel Create(EntityViewModel evm)
8782 private readonly List < ModelFactory > _modelFactories = new List < ModelFactory > ( ) ;
8883 private readonly List < Delegate > _controlFactories = new List < Delegate > ( ) ;
8984
90- private readonly List < WeakReference < EntityViewModel > > _boundEntityViewModels = new List < WeakReference < EntityViewModel > > ( ) ;
91- private readonly ConditionalWeakTable < EntityViewModel , MtObservableList < EntityControlViewModel > > _boundViewModels = new ConditionalWeakTable < EntityViewModel , MtObservableList < EntityControlViewModel > > ( ) ;
85+ private readonly ObservableConcurrentList < WeakReference < EntityViewModel > > _boundEntityViewModels = new ObservableConcurrentList < WeakReference < EntityViewModel > > ( ) ;
86+ private readonly ConditionalWeakTable < EntityViewModel , ObservableConcurrentList < EntityControlViewModel > > _boundViewModels = new ConditionalWeakTable < EntityViewModel , ObservableConcurrentList < EntityControlViewModel > > ( ) ;
9287
9388 /// <summary>
9489 /// This factory will be used to create component models for matching entity models.
@@ -109,14 +104,14 @@ public void RegisterModelFactory<TEntityBaseModel>(Func<TEntityBaseModel, Entity
109104 while ( i < _boundEntityViewModels . Count )
110105 {
111106 if ( _boundEntityViewModels [ i ] . TryGetTarget ( out EntityViewModel target ) &&
112- _boundViewModels . TryGetValue ( target , out MtObservableList < EntityControlViewModel > components ) )
107+ _boundViewModels . TryGetValue ( target , out ObservableConcurrentList < EntityControlViewModel > components ) )
113108 {
114109 if ( target is TEntityBaseModel tent )
115110 UpdateBinding ( target , components ) ;
116111 i ++ ;
117112 }
118113 else
119- _boundEntityViewModels . RemoveAtFast ( i ) ;
114+ _boundEntityViewModels . RemoveAt ( i ) ;
120115 }
121116 }
122117 }
@@ -190,15 +185,15 @@ private void RefreshControls<TEntityComponentModel>() where TEntityComponentMode
190185 while ( i < _boundEntityViewModels . Count )
191186 {
192187 if ( _boundEntityViewModels [ i ] . TryGetTarget ( out EntityViewModel target ) &&
193- _boundViewModels . TryGetValue ( target , out MtObservableList < EntityControlViewModel > components ) )
188+ _boundViewModels . TryGetValue ( target , out ObservableConcurrentList < EntityControlViewModel > components ) )
194189 {
195190 foreach ( EntityControlViewModel component in components )
196191 if ( component is TEntityComponentModel )
197192 component . InvalidateControl ( ) ;
198193 i ++ ;
199194 }
200195 else
201- _boundEntityViewModels . RemoveAtFast ( i ) ;
196+ _boundEntityViewModels . RemoveAt ( i ) ;
202197 }
203198 }
204199
@@ -207,7 +202,7 @@ private void RefreshControls<TEntityComponentModel>() where TEntityComponentMode
207202 /// </summary>
208203 /// <param name="entity">view model to query</param>
209204 /// <returns></returns>
210- public MtObservableList < EntityControlViewModel > BoundModels ( EntityViewModel entity )
205+ public ObservableConcurrentList < EntityControlViewModel > BoundModels ( EntityViewModel entity )
211206 {
212207 return _boundViewModels . GetValue ( entity , CreateFreshBinding ) ;
213208 }
@@ -231,9 +226,9 @@ public Control CreateControl(EntityControlViewModel model)
231226 return null ;
232227 }
233228
234- private MtObservableList < EntityControlViewModel > CreateFreshBinding ( EntityViewModel key )
229+ private ObservableConcurrentList < EntityControlViewModel > CreateFreshBinding ( EntityViewModel key )
235230 {
236- var binding = new MtObservableList < EntityControlViewModel > ( ) ;
231+ var binding = new ObservableConcurrentList < EntityControlViewModel > ( ) ;
237232 lock ( this )
238233 {
239234 _boundEntityViewModels . Add ( new WeakReference < EntityViewModel > ( key ) ) ;
@@ -246,7 +241,7 @@ private MtObservableList<EntityControlViewModel> CreateFreshBinding(EntityViewMo
246241 return binding ;
247242 }
248243
249- private void UpdateBinding ( EntityViewModel key , MtObservableList < EntityControlViewModel > binding )
244+ private void UpdateBinding ( EntityViewModel key , ObservableConcurrentList < EntityControlViewModel > binding )
250245 {
251246 if ( ! binding . IsObserved )
252247 return ;
0 commit comments