public LiveTradesViewer(ITradeService tradeService, SearchHints searchHints) { SearchHints = searchHints; Data = tradeService.Live .CollectionPausing(() => Paused) .Filtering(t => t.CurrencyPair.Contains(SearchHints.SearchTextThrottled.Value, StringComparison.OrdinalIgnoreCase) || t.Customer.Contains(SearchHints.SearchTextThrottled.Value, StringComparison.OrdinalIgnoreCase)) .Ordering(t => t.Timestamp, ListSortDirection.Descending) .Selecting(t => new TradeProxy(t)) .CollectionDisposing() .For(_consumer); }
public LiveTradesViewer(ITradeService tradeService, SearchHints searchHints, OcDispatcher backgroundOcDispatcher, WpfOcDispatcher wpfOcDispatcher) { SearchHints = searchHints; Data = tradeService.Live .CollectionPausing(new Computing <bool>(() => Paused).ScalarDispatching(backgroundOcDispatcher, wpfOcDispatcher)) .Filtering(t => t.CurrencyPair.Contains(SearchHints.SearchTextThrottled.Value, StringComparison.OrdinalIgnoreCase) || t.Customer.Contains(SearchHints.SearchTextThrottled.Value, StringComparison.OrdinalIgnoreCase)) .Ordering(t => t.Timestamp, ListSortDirection.Descending) .Selecting(t => new TradeProxy(t)) .CollectionDisposing() .CollectionDispatching(wpfOcDispatcher, backgroundOcDispatcher, 0, 1) .For(_consumer); }
public LiveTradesViewer(ITradeService tradeService, SearchHints searchHints) { SearchHints = searchHints; var filter = SearchHints.WhenValueChanged(t => t.SearchText) .Select(BuildFilter); var loader = tradeService.Live.Connect() .BatchIf(this.WhenValueChanged(x => x.Paused), null, null) //I need to fix the API, so nulls do not have to be passed in .Filter(filter) // apply user filter .Transform(trade => new TradeProxy(trade)) .Sort(SortExpressionComparer <TradeProxy> .Descending(t => t.Timestamp), SortOptimisations.ComparesImmutableValuesOnly, 25) .ObserveOnDispatcher() .Bind(out _data) // update observable collection bindings .DisposeMany() //since TradeProxy is disposable dispose when no longer required .Subscribe(); _cleanUp = new CompositeDisposable(loader, searchHints); }
public LiveTradesViewer(ITradeService tradeService, SearchHints searchHints) { _searchHints = searchHints; var filter = SearchHints.WhenValueChanged(t => t.SearchText) .Select(BuildFilter); var loader = tradeService.Live.Connect() .Filter(filter) // apply user filter //if targeting dotnet 4.5 can parallelise 'cause it's quicker .Transform(trade => new TradeProxy(trade), new ParallelisationOptions(ParallelType.Ordered, 5)) .Sort(SortExpressionComparer <TradeProxy> .Descending(t => t.Timestamp), SortOptimisations.ComparesImmutableValuesOnly) .ObserveOnDispatcher() .Bind(out _data) // update observable collection bindings .DisposeMany() //since TradeProxy is disposable dispose when no longer required .Subscribe(); _cleanUp = new CompositeDisposable(loader, searchHints); }
public LiveTradesViewer(ITradeService tradeService,SearchHints searchHints) { _searchHints = searchHints; var filter = SearchHints.WhenValueChanged(t => t.SearchText) .Select(BuildFilter); var loader = tradeService.Live.Connect() .Filter(filter) // apply user filter //if targeting dotnet 4.5 can parallelise 'cause it's quicker .Transform(trade => new TradeProxy(trade),new ParallelisationOptions(ParallelType.Ordered,5)) .Sort(SortExpressionComparer<TradeProxy>.Descending(t => t.Timestamp),SortOptimisations.ComparesImmutableValuesOnly) .ObserveOnDispatcher() .Bind(out _data) // update observable collection bindings .DisposeMany() //since TradeProxy is disposable dispose when no longer required .Subscribe(); _cleanUp = new CompositeDisposable(loader, searchHints); }
public PagedDataViewer(ITradeService tradeService, SearchHints searchHints) { SearchHints = searchHints; SortParameters = new SortParameterData( tradeService.Live .Selecting(t => new TradeProxy(t)) .CollectionDisposing(), _consumer); AllData = new Computing <ObservableCollection <TradeProxy> >( () => SortParameters.SelectedItem.SortedData) .Filtering(t => t.Trade.CurrencyPair.Contains(SearchHints.SearchTextThrottled.Value, StringComparison.OrdinalIgnoreCase) || t.Trade.Customer.Contains(SearchHints.SearchTextThrottled.Value, StringComparison.OrdinalIgnoreCase)); Data = AllData.Paging(25, 1).For(_consumer); _nextPageCommand = new Command(() => Data.CurrentPage = Data.CurrentPage + 1, () => Data.CurrentPage < Data.PageCount); _previousPageCommand = new Command(() => Data.CurrentPage = Data.CurrentPage - 1, () => Data.CurrentPage > 1); }
public LiveTradesViewer(ILogger logger, ITradeService tradeService, SearchHints searchHints) { _logger = logger; _searchHints = searchHints; var filter = new FilterController <Trade>(trade => true); var filterApplier = SearchHints.ObservePropertyValue(t => t.SearchText) .Throttle(TimeSpan.FromMilliseconds(250)) .Select(propargs => BuildFilter(propargs.Value)) .Subscribe(filter.Change); var loader = tradeService.All .Connect(trade => trade.Status == TradeStatus.Live) //prefilter live trades only .Filter(filter) // apply user filter //if using dotnet 4.5 can parallelise 'case it's quicler .Transform(trade => new TradeProxy(trade), new ParallelisationOptions(ParallelType.Ordered, 5)) .Sort(SortExpressionComparer <TradeProxy> .Descending(t => t.Timestamp), SortOptimisations.ComparesImmutableValuesOnly) .ObserveOnDispatcher() .Bind(_data) // update observable collection bindings .DisposeMany() //since TradeProxy is disposable dispose when no longer required .Subscribe(); _cleanUp = new CompositeDisposable(loader, filter, filterApplier, searchHints); }
public LiveTradesViewer(ILogger logger,ITradeService tradeService,SearchHints searchHints) { _logger = logger; _searchHints = searchHints; var filter = new FilterController<Trade>(trade=>true); var filterApplier = SearchHints.ObservePropertyValue(t => t.SearchText) .Throttle(TimeSpan.FromMilliseconds(250)) .Select(propargs=>BuildFilter(propargs.Value)) .Subscribe(filter.Change); var loader = tradeService.All .Connect(trade => trade.Status == TradeStatus.Live) //prefilter live trades only .Filter(filter) // apply user filter //if using dotnet 4.5 can parallelise 'case it's quicler .Transform(trade => new TradeProxy(trade),new ParallelisationOptions(ParallelType.Ordered,5)) .Sort(SortExpressionComparer<TradeProxy>.Descending(t => t.Timestamp),SortOptimisations.ComparesImmutableValuesOnly) .ObserveOnDispatcher() .Bind(_data) // update observable collection bindings .DisposeMany() //since TradeProxy is disposable dispose when no longer required .Subscribe(); _cleanUp = new CompositeDisposable(loader, filter, filterApplier, searchHints); }
public void Dispose() { _consumer.Dispose(); SearchHints.Dispose(); }