Пример #1
0
        public FxClientViewModel(IFxDataService dataService)
        {
            _dataService            = dataService;
            CurrencyPairs           = new ObservableCollection <FxCurrencyPairViewModel>();
            _currenciesSubscription = _dataService.Currencies.ReplayAndSubscribe(
                update =>
            {
                if (update.Action == TableUpdateAction.Add)
                {
                    CurrencyPairs.Add(new FxCurrencyPairViewModel(_dataService.Currencies, update.RowIndex));
                }
            });

            FxRates = new ObservableCollection <FxRateViewModel>();
            _fxRatesSubscription = _dataService.FxRates.ReplayAndSubscribe(
                update =>
            {
                if (update.Action == TableUpdateAction.Add)
                {
                    FxRates.Add(new FxRateViewModel(_dataService.FxRates, update.RowIndex));
                }
            });

            _dataService.Start(Application.Current.Dispatcher);
        }
        public FxClientSyncfusionViewModel(IFxDataService dataService)
        {
            _dataService = dataService;
            var ratesTable = dataService.FxRates;

            _sortedRates = new SortedTable(ratesTable);
            _sortedRates.SortBy(FxTableDefinitions.FxRates.CcyPairId, Comparer <string> .Default);
            SetTable(_sortedRates);

            _columnTypes = new Dictionary <string, Type>
            {
                { FxTableDefinitions.FxRates.CcyPairId, typeof(string) },
                { FxTableDefinitions.FxRates.Bid, typeof(double) },
                { FxTableDefinitions.FxRates.Ask, typeof(double) },
                { FxTableDefinitions.FxRates.Open, typeof(double) },
                { FxTableDefinitions.FxRates.Close, typeof(double) },
                { FxTableDefinitions.FxRates.Change, typeof(double) },
                { FxTableDefinitions.FxRates.YearRangeStart, typeof(double) },
                { FxTableDefinitions.FxRates.YearRangeEnd, typeof(double) },
                { FxTableDefinitions.FxRates.Time, typeof(DateTime) },
                { FxTableDefinitions.FxRates.Ticks, typeof(double) },
            };
            Columns = new ObservableCollection <string>(_columnTypes.Keys);

            dataService.Start(Application.Current.Dispatcher);
        }