public static ReadOnlyDispatcherCollectionRx<TViewModel> CreateReadOnlyDispatcherCollectionRx <TModel, TViewModel>(ObservableSynchronizedCollectionEx<TModel> source, Func<TModel, TViewModel> converter, Dispatcher dispatcher, DispatcherPriority priority = DispatcherPriority.Normal) { if (source == null) throw new ArgumentNullException("source"); if (!DispatcherHelper.UIDispatcher.CheckAccess()) { throw new ArgumentException("This method must be called on the Dispatcher thread."); } var sourceAsNotifyCollection = source as INotifyCollectionChanged; if (sourceAsNotifyCollection == null) throw new ArgumentException("sourceがINotifyCollectionChangedを実装していません"); var initCollection = new ObservableCollection<TViewModel>(); var target = new DispatcherCollectionRx<TViewModel>(initCollection, dispatcher) { CollectionChangedDispatcherPriority = priority }; var result = new ReadOnlyDispatcherCollectionRx<TViewModel>(target); source.SynchronizedToArray(array => { foreach (var model in array) { initCollection.Add(converter(model)); } result.Disposables.Add(CreateSubscription(sourceAsNotifyCollection, converter, target)); }); return result; }
internal AccountManager(Setting.SettingItem <List <TwitterAccount> > settingItem) { _settingItem = settingItem ?? throw new ArgumentNullException(nameof(settingItem)); _accountObservableCollection = new ObservableSynchronizedCollectionEx <TwitterAccount>(_settingItem.Value); _accountCache = new ConcurrentDictionary <long, TwitterAccount>( _accountObservableCollection.Distinct(a => a.Id).ToDictionary(a => a.Id)); _accountObservableCollection.CollectionChanged += CollectionChanged; _random = new Random(Environment.TickCount); // initialize DB after system is available. App.SystemReady += SynchronizeDb; }
internal AccountManager(Setting.SettingItem<List<TwitterAccount>> settingItem) { if (settingItem == null) { throw new ArgumentNullException("settingItem"); } this._settingItem = settingItem; _accountObservableCollection = new ObservableSynchronizedCollectionEx<TwitterAccount>(_settingItem.Value); _accountCache = new ConcurrentDictionary<long, TwitterAccount>( _accountObservableCollection.ToDictionary(a => a.Id)); _accountObservableCollection.CollectionChanged += CollectionChanged; _random = new Random(Environment.TickCount); }
public TimelineModelBase() { _statusIdCache = new HashSet<long>(); _statuses = new ObservableSynchronizedCollectionEx<StatusModel>(); }
public TimelineModelBase() { this._statusIdCache = new HashSet <long>(); this._statuses = new ObservableSynchronizedCollectionEx <StatusModel>(); }
public TimelineModelBase() { this._statusIdCache = new AVLTree<long>(); this._statuses = new ObservableSynchronizedCollectionEx<StatusModel>(); }