Ejemplo n.º 1
0
 public ConstantRatePump(IConcurrencyService concurrencyService)
 {
     _tick = Observable.Timer(TimeSpan.Zero, TimeSpan.FromMilliseconds(125), concurrencyService.Dispatcher)
                       .Select(_ => Unit.Default)   // Use underscore (_) as a parameter name to indicate that it is ignored/not used
                       .Publish()
                       .RefCount();
 }
        public ObservablesListItem(IConcurrencyService concurrencyService)
        {
            mSubscriptionCount = ObservableAsPropertyHelper <int> .Default();

            this.WhenActivated((CompositeDisposable disposables) =>
            {
                var subCount = ObservableInstance.Subscriptions
                               .Publish(subs => subs
                                        .ToObservableChangeSet(sub => sub.SubscriptionId)
                                        .Merge(subs.SelectMany(sub => sub.Events
                                                               .TakeUntil(e => e.Kind == OnCompleted || e.Kind == OnError || e.Kind == Unsubscribe)
                                                               .WhenTerminated()
                                                               .Select(_ => new Change <ISubscription, long>(ChangeReason.Remove, sub.SubscriptionId, sub))
                                                               .Select(chg => new ChangeSet <ISubscription, long> {
                    chg
                }))))
                               .AsObservableCache()
                               .CountChanged
                               .TakeUntilDisposed(disposables)
                               .SubscribeOn(concurrencyService.TaskPoolRxScheduler)
                               .ObserveOn(concurrencyService.DispatcherRxScheduler)
                               .Publish();

                subCount
                .ToProperty(this, x => x.SubscriptionCount, out mSubscriptionCount)
                .DisposeWith(disposables);

                subCount.Connect();
            });
        }
        public ConnectivityStatusViewModel(
            IReactiveTrader reactiveTrader,
            IConcurrencyService concurrencyService,
            ILoggerFactory loggerFactory,
            IProcessorMonitor processorMonitor)
        {
            _processorMonitor     = processorMonitor;
            _priceLatencyRecorder = reactiveTrader.PriceLatencyRecorder;
            var log = loggerFactory.Create(typeof(ConnectivityStatusViewModel));

            if (!_processorMonitor.IsAvailable)
            {
                CpuPercent = "N/A";
                CpuTime    = "N/A";
            }

            _subscriptions.Add(reactiveTrader.ConnectionStatusStream
                               .ObserveOn(concurrencyService.Dispatcher)
                               .SubscribeOn(concurrencyService.TaskPool)
                               .Subscribe(
                                   OnStatusChange,
                                   ex => log.Error("An error occurred within the connection status stream.", ex)));

            _subscriptions.Add(Observable
                               .Interval(StatsFrequency, concurrencyService.Dispatcher)
                               .Subscribe(_ => OnTimerTick()));
        }
Ejemplo n.º 4
0
        public ObservablesListViewModel(IConcurrencyService concurrencyService, IObservablesScreenItemFactory factory)
        {
            var items = new ObservableCollectionExtended <ObservablesListItem>();

            Items = new ReadOnlyObservableCollection <ObservablesListItem>(items);

            WhenSelectionChanges = mWhenSelectionChanges
                                   .ObserveOn(concurrencyService.TaskPoolRxScheduler)
                                   .AddKey(item => item.ObservableInstance.ObservableId)
                                   .Transform(item => item.ObservableInstance)
                                   .AsObservableCache()
                                   .Connect();

            this.WhenActivated((CompositeDisposable disposables) =>
            {
                Observables
                .Transform(obs => factory.CreateItem(obs))
                .Sort(Utility.Comparer <ObservablesListItem> .ByKey(x => - x.ObservableInstance.ObservableId))
                .SubscribeOn(concurrencyService.TaskPoolRxScheduler)
                .ObserveOn(concurrencyService.DispatcherRxScheduler)
                .Bind(items)
                .Transform(item => item.Activator.Activate())
                .DisposeMany()
                .Subscribe()
                .DisposeWith(disposables);
            });
        }
Ejemplo n.º 5
0
 public KeysController(ObservableCollection <Message> keys, IMessageProvider messageProvider, IKeyProvider keyProvider, IConcurrencyService concurrencyService)
 {
     this.keys               = keys;
     this.messageProvider    = messageProvider;
     this.keyProvider        = keyProvider;
     this.concurrencyService = concurrencyService;
 }
        public void Setup()
        {
            _serviceProviderMock = new Mock <IServiceProvider>();

            _navigationStateProvider = new Mock <INavigationStateProvider>();

            _entityVariant = new EntityVariantSetup("ev", "icon", typeof(IEntity), "alias");
            _collection    = new CollectionSetup("icon", "color", "name", "alias", "repo")
            {
                EntityVariant = _entityVariant
            };
            _collectionResolver = new Mock <ISetupResolver <CollectionSetup> >();
            _collectionResolver
            .Setup(x => x.ResolveSetupAsync(It.IsAny <string>()))
            .ReturnsAsync(_collection);

            _repositoryResolver = new Mock <IRepositoryResolver>();
            _concurrencyService = new ConcurrencyService(new SemaphoreSlim(1, 1));
            _buttonInteraction  = new Mock <IButtonInteraction>();
            _editContextFactory = new Mock <IEditContextFactory>();
            _mediator           = new Mock <IMediator>();

            _subject = new EntityInteractionDispatcher(
                _navigationStateProvider.Object,
                _collectionResolver.Object,
                _repositoryResolver.Object,
                _concurrencyService,
                _buttonInteraction.Object,
                _editContextFactory.Object,
                _mediator.Object);
        }
 public ConstantRatePump(IConcurrencyService concurrencyService, IConstantRateConfigurationProvider configurationProvider)
 {
     _tick = Observable.Timer(TimeSpan.Zero, configurationProvider.ConstantRate, concurrencyService.Dispatcher)
                       .Select(_ => Unit.Default)   // Use underscore (_) as a parameter name to indicate that it is ignored/not used
                       .Publish()
                       .RefCount();
 }
 public TickerViewModelFactory(
     IReactiveTrader reactiveTrader,
     IConcurrencyService concurrencyService)
 {
     this.reactiveTrader = reactiveTrader;
     this.concurrencyService = concurrencyService;
 }
Ejemplo n.º 9
0
        public SpotTilesViewModel(IReactiveTrader reactiveTrader,
            Func<ICurrencyPair, SpotTileSubscriptionMode, ISpotTileViewModel> spotTileFactory,
            IConcurrencyService concurrencyService,
            ILoggerFactory loggerFactory)
        {
            _referenceDataRepository = reactiveTrader.ReferenceData;
            _spotTileFactory = spotTileFactory;
            _concurrencyService = concurrencyService;
            _log = loggerFactory.Create(typeof (SpotTilesViewModel));

            SpotTiles = new ObservableCollection<ISpotTileViewModel>();

            _config = spotTileFactory(null, SpotTileSubscriptionMode.Conflate);
            _config.ToConfig();

            SpotTiles.Add(_config);

            _subscriptions.Add(
                _config.Config.ObserveProperty(p => p.SubscriptionMode)
                    .Subscribe(subscriptionMode => SpotTiles.Where(vm => vm.Pricing != null).ForEach(vm => vm.Pricing.SubscriptionMode = subscriptionMode)));

            _subscriptions.Add(
                _config.Config.ObserveProperty(p => p.ExecutionMode)
                    .Subscribe(executionMode => SpotTiles.Where(vm => vm.Pricing != null).ForEach(vm => vm.Pricing.ExecutionMode = executionMode)));

            LoadSpotTiles();
        }
Ejemplo n.º 10
0
        public SpotTilePricingViewModel(ICurrencyPair currencyPair, SpotTileSubscriptionMode spotTileSubscriptionMode, ISpotTileViewModel parent,
                                        Func <Direction, ISpotTilePricingViewModel, IOneWayPriceViewModel> oneWayPriceFactory,
                                        IReactiveTrader reactiveTrader,
                                        IConcurrencyService concurrencyService,
                                        IConstantRatePump constantRatePump,
                                        ILoggerFactory loggerFactory)
        {
            _currencyPair         = currencyPair;
            _subscriptionMode     = spotTileSubscriptionMode;
            _parent               = parent;
            _priceLatencyRecorder = reactiveTrader.PriceLatencyRecorder;
            _concurrencyService   = concurrencyService;
            _constantRatePump     = constantRatePump;
            _log = loggerFactory.Create(typeof(SpotTilePricingViewModel));

            _priceSubscription = new SerialDisposable();
            Bid           = oneWayPriceFactory(Direction.SELL, this);
            Ask           = oneWayPriceFactory(Direction.BUY, this);
            Notional      = "1000000";
            DealtCurrency = currencyPair.BaseCurrency;
            SpotDate      = "SP";
            IsSubscribing = true;

            SubscribeForPrices();
        }
        public SelectedCallsScreenViewModel(ISelectionService selectionService, IConcurrencyService concurrencyService,
                                            IObservablesList observablesListViewModel)
        {
            ObservablesList = observablesListViewModel;
            DisplayName     = "IObservable instances";

            observablesListViewModel.Observables = selectionService.WhenSelectionChanges
                                                   .ObserveOn(concurrencyService.TaskPoolRxScheduler)
                                                   .Select(selection => selection.SelectedInstrumentedCalls)
                                                   .DistinctUntilChanged()
                                                   .Select(calls => calls
                                                           .Select(c => c.ObservableInstances)
                                                           .Merge()
                                                           .ToObservableChangeSet(obs => obs.ObservableId))
                                                   .SwitchFixed();

            this.WhenActivated((CompositeDisposable disposables) =>
            {
                observablesListViewModel.WhenSelectionChanges
                .OnItemAdded(obs => selectionService.ChangeSelection(s => s.AddObservableInstance(obs)))
                .OnItemRemoved(obs => selectionService.ChangeSelection(s => s.RemoveObservableInstance(obs)))
                .Subscribe()
                .DisposeWith(disposables);

                observablesListViewModel.Activator.Activate()
                .DisposeWith(disposables);
            });
        }
        public CollectionDataProvider(
            IRepository repository,
            IConcurrencyService concurrencyService,
            string?repositoryAlias,
            string?collectionAlias,
            IPropertyMetadata?relatedElementsGetter,
            bool entityAsParent,
            IPropertyMetadata?repositoryParentSelector,
            IPropertyMetadata idProperty,
            IReadOnlyList <IExpressionMetadata> displayProperties,
            Type relatedEntityType,
            IPropertyMetadata property,
            IMediator mediator)
        {
            _repository               = repository ?? throw new ArgumentNullException(nameof(repository));
            _concurrencyService       = concurrencyService;
            _repositoryAlias          = repositoryAlias;
            _collectionAlias          = collectionAlias;
            _relatedElementsGetter    = relatedElementsGetter;
            _entityAsParent           = entityAsParent;
            _repositoryParentSelector = repositoryParentSelector;
            _idProperty               = idProperty ?? throw new ArgumentNullException(nameof(idProperty));
            _displayProperties        = displayProperties ?? throw new ArgumentNullException(nameof(displayProperties));
            _relatedEntityType        = relatedEntityType ?? throw new ArgumentNullException(nameof(relatedEntityType));
            _property = property ?? throw new ArgumentNullException(nameof(property));
            _mediator = mediator ?? throw new ArgumentNullException(nameof(mediator));

            _eventHandle = _mediator.RegisterCallback <CollectionRepositoryEventArgs>(OnRepositoryChangeAsync);
        }
        public TradesViewController(IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService)
            : base(UITableViewStyle.Plain)
        {
            _reactiveTrader     = reactiveTrader;
            _concurrencyService = concurrencyService;

            Title            = "Trades";
            TabBarItem.Image = UIImage.FromBundle("tab_trades");

            _model = new TradeTilesModel(_reactiveTrader, _concurrencyService);

            _model.DoneTrades.CollectionChanged += (sender, e) => {
                // todo - handle insertions/removals properly
                UITableView table = this.TableView;

                if (table != null)
                {
                    if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add &&
                        e.NewItems.Count == 1)
                    {
                        table.InsertRows(
                            new [] {
                            NSIndexPath.Create(0, e.NewStartingIndex)
                        }, UITableViewRowAnimation.Top);
                    }
                    else
                    {
                        table.ReloadData();
                    }
                }
            };

            _model.Initialise();
        }
		public TradesViewController (IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService)
			: base (UITableViewStyle.Plain)
		{
			_reactiveTrader = reactiveTrader;
			_concurrencyService = concurrencyService;

			Title = "Trades";
			TabBarItem.Image = UIImage.FromBundle ("tab_trades");

			_model = new TradeTilesModel (_reactiveTrader, _concurrencyService);

			_model.DoneTrades.CollectionChanged += (sender, e) => {
				// todo - handle insertions/removals properly
				UITableView table = this.TableView;

				if (table != null) {
					if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add
						&& e.NewItems.Count == 1) {
						table.InsertRows (
							new [] {
								NSIndexPath.Create (0, e.NewStartingIndex)
							}, UITableViewRowAnimation.Top);
					} else {
						table.ReloadData ();
					}
				}
			};

			_model.Initialise ();
		}
Ejemplo n.º 15
0
        public EventListScreenViewModel(
            IConcurrencyService concurrencyService,
            ISelectionService selectionService,
            IEventList eventList)
        {
            eventList.WhenEventSelectionChanges.Subscribe(selectionService.ChangeSelection);
            eventList.IncludeInputObservables = this.WhenAnyValue(x => x.IncludeInputObservables)
                                                .ObserveOn(concurrencyService.TaskPoolRxScheduler);

            EventList = eventList;

            this.WhenActivated(disposables =>
            {
                var observablesForCalls = mDocument.Calls
                                          .ObserveOn(concurrencyService.TaskPoolRxScheduler)
                                          .TakeWhile(change => change.Removes == 0) // stop if any calls removed
                                          .MergeMany(call => call.ObservableInstances)
                                          .ToObservableChangeSet(obs => obs.ObservableId)
                                          .Repeat(); // reset after calls removed

                eventList.Observables = mDocument.Observables.Or(observablesForCalls);

                eventList.Activator.Activate().DisposeWith(disposables);
            });
        }
        public MarbleObservableItem(IConcurrencyService concurrencyService)
        {
            StreamEventsViewModel = new StreamEventsViewModel(concurrencyService);

            var subItems = new ObservableCollection <MarbleSubscriptionItem>();

            SubscriptionItems = new ReadOnlyObservableCollection <MarbleSubscriptionItem>(subItems);

            this.WhenActivated(disposables =>
            {
                subItems.Clear();

                ObservableInstance.Subscriptions
                .Select(sub => new MarbleSubscriptionItem(concurrencyService)
                {
                    Subscription = sub
                })
                .ObserveOn(concurrencyService.DispatcherRxScheduler)
                .Subscribe(subItems.Add)
                .DisposeWith(disposables);

                StreamEventsViewModel.StreamEventsSource = ObservableInstance.Subscriptions
                                                           .SelectMany(sub => sub.Events);
            });
        }
Ejemplo n.º 17
0
        public SpotTilesViewModel(IReactiveTrader reactiveTrader,
                                  Func <ICurrencyPair, SpotTileSubscriptionMode, ISpotTileViewModel> spotTileFactory,
                                  IConcurrencyService concurrencyService,
                                  ILoggerFactory loggerFactory)
        {
            _referenceDataRepository = reactiveTrader.ReferenceData;
            _spotTileFactory         = spotTileFactory;
            _concurrencyService      = concurrencyService;
            _log = loggerFactory.Create(typeof(SpotTilesViewModel));

            SpotTiles = new ObservableCollection <ISpotTileViewModel>();

            _config = spotTileFactory(null, SpotTileSubscriptionMode.Conflate);
            _config.ToConfig();

            SpotTiles.Add(_config);

            _subscriptions.Add(
                _config.Config.ObserveProperty(p => p.SubscriptionMode)
                .Subscribe(subscriptionMode => SpotTiles.Where(vm => vm.Pricing != null).ForEach(vm => vm.Pricing.SubscriptionMode = subscriptionMode)));

            _subscriptions.Add(
                _config.Config.ObserveProperty(p => p.ExecutionMode)
                .Subscribe(executionMode => SpotTiles.Where(vm => vm.Pricing != null).ForEach(vm => vm.Pricing.ExecutionMode = executionMode)));

            LoadSpotTiles();
        }
        public void Setup()
        {
            _serviceProviderMock = new Mock <IServiceProvider>();

            _pageState = new Mock <IPageState>();

            _entityVariant = new Mock <IEntityVariantSetup>();
            _collection    = new Mock <ICollectionSetup>();
            _collection
            .Setup(x => x.GetEntityVariant(It.IsAny <IEntity>()))
            .Returns(_entityVariant.Object);
            _collectionResolver = new Mock <ISetupResolver <ICollectionSetup> >();
            _collectionResolver
            .Setup(x => x.ResolveSetup(It.IsAny <string>()))
            .Returns(_collection.Object);

            _repositoryResolver = new Mock <IRepositoryResolver>();
            _concurrencyService = new ConcurrencyService(new SemaphoreSlim(1, 1));
            _buttonInteraction  = new Mock <IButtonInteraction>();
            _editContextFactory = new Mock <IEditContextFactory>();

            _subject = new EntityInteractionDispatcher(
                _collectionResolver.Object,
                _repositoryResolver.Object,
                _concurrencyService,
                _buttonInteraction.Object,
                _editContextFactory.Object);
        }
        public ConnectivityStatusViewModel(
            IReactiveTrader reactiveTrader, 
            IConcurrencyService concurrencyService, 
            ILoggerFactory loggerFactory,
            IProcessorMonitor processorMonitor)
        {
            _processorMonitor = processorMonitor;
            _priceLatencyRecorder = reactiveTrader.PriceLatencyRecorder;
            var log = loggerFactory.Create(typeof (ConnectivityStatusViewModel));

            if (!_processorMonitor.IsAvailable)
            {
                CpuPercent = "N/A";
                CpuTime = "N/A";
            }

            _subscriptions.Add(reactiveTrader.ConnectionStatusStream
                .ObserveOn(concurrencyService.Dispatcher)
                .SubscribeOn(concurrencyService.TaskPool)
                .Subscribe(
                OnStatusChange,
                ex => log.Error("An error occurred within the connection status stream.", ex)));

            _subscriptions.Add(Observable
                .Interval(StatsFrequency, concurrencyService.Dispatcher)
                .Subscribe(_ => OnTimerTick()));
        }
Ejemplo n.º 20
0
 public TickerViewModelFactory(
     IReactiveTrader reactiveTrader,
     IConcurrencyService concurrencyService)
 {
     this.reactiveTrader     = reactiveTrader;
     this.concurrencyService = concurrencyService;
 }
        public SpotTilePricingViewModel(ICurrencyPair currencyPair, SpotTileSubscriptionMode spotTileSubscriptionMode, ISpotTileViewModel parent,
            Func<Direction, ISpotTilePricingViewModel, IOneWayPriceViewModel> oneWayPriceFactory,
            IReactiveTrader reactiveTrader,
            IConcurrencyService concurrencyService,
            IConstantRatePump constantRatePump,
            ILoggerFactory loggerFactory)
        {
            _currencyPair = currencyPair;
            _subscriptionMode = spotTileSubscriptionMode;
            _parent = parent;
            _priceLatencyRecorder = reactiveTrader.PriceLatencyRecorder;
            _concurrencyService = concurrencyService;
            _constantRatePump = constantRatePump;
            _log = loggerFactory.Create(typeof(SpotTilePricingViewModel));

            _priceSubscription = new SerialDisposable();
            Bid = oneWayPriceFactory(Direction.SELL, this);
            Ask = oneWayPriceFactory(Direction.BUY, this);
            Notional = "1000000";
            DealtCurrency = currencyPair.BaseCurrency;
            SpotDate = "SP";
            IsSubscribing = true;

            SubscribeForPrices();
        }
Ejemplo n.º 22
0
 public ConstantRatePump(IConcurrencyService concurrencyService)
 {
     _tick = Observable.Timer(TimeSpan.Zero, TimeSpan.FromMilliseconds(125), concurrencyService.Dispatcher)
             .Select(_ => Unit.Default)             // Use underscore (_) as a parameter name to indicate that it is ignored/not used
             .Publish()
             .RefCount();
 }
Ejemplo n.º 23
0
 public ConstantRatePump(IConcurrencyService concurrencyService, IConstantRateConfigurationProvider configurationProvider)
 {
     Tick = Observable.Timer(TimeSpan.Zero, configurationProvider.ConstantRate, concurrencyService.Dispatcher)
            .Select(_ => Unit.Default)              // Use underscore (_) as a parameter name to indicate that it is ignored/not used
            .Publish()
            .RefCount();
 }
Ejemplo n.º 24
0
 public WampServiceClientContainer(string server, string userName, IConcurrencyService concurrencyService, ILoggerFactory loggerFactory)
 {
     _statusStream       = new BehaviorSubject <ConnectionInfo>(new ConnectionInfo(ConnectionStatus.Uninitialized, server, TransportName));
     _connection         = new WampConnection(server, userName, loggerFactory);
     _server             = server;
     _concurrencyService = concurrencyService;
     _loggerFactory      = loggerFactory;
 }
Ejemplo n.º 25
0
        public OneWayPriceViewModel(Direction direction, ISpotTilePricingViewModel parent, IConcurrencyService concurrencyService)
        {
            _parent = parent;
            _concurrencyService = concurrencyService;
            Direction = direction;

            _executeCommand = new DelegateCommand(OnExecute, CanExecute);
        }
Ejemplo n.º 26
0
        public OneWayPriceViewModel(Direction direction, ISpotTilePricingViewModel parent, IConcurrencyService concurrencyService, ILoggerFactory loggerFactory)
        {
            _parent = parent;
            _concurrencyService = concurrencyService;
            Direction = direction;
            _log = loggerFactory.Create(typeof (OneWayPriceViewModel));

            _executeCommand = new DelegateCommand(OnExecute, CanExecute);
        }
Ejemplo n.º 27
0
        public MarbleSubscriptionItem(IConcurrencyService concurrencyService)
        {
            StreamEventsViewModel = new StreamEventsViewModel(concurrencyService);

            this.WhenActivated((CompositeDisposable _) =>
            {
                StreamEventsViewModel.StreamEventsSource = Subscription.Events;
            });
        }
        public OneWayPriceViewModel(Direction direction, ISpotTilePricingViewModel parent, IConcurrencyService concurrencyService, ILoggerFactory loggerFactory)
        {
            _parent             = parent;
            _concurrencyService = concurrencyService;
            Direction           = direction;
            _log = loggerFactory.Create(typeof(OneWayPriceViewModel));

            _executeCommand = new DelegateCommand(OnExecute, CanExecute);
        }
Ejemplo n.º 29
0
        public Rfq(IRfqService rfqService, IConcurrencyService concurrencyService)
        {
            _rfqService = rfqService;
            _concurrencyService = concurrencyService;
            _stateMachine = new StateMachine<RfqState, RfqEvent>(RfqState.Input);
            _rfqUpdateSubject = new BehaviorSubject<RfqUpdate>(new RfqUpdate(RfqState.Input, null, null));
            _disposables = new CompositeDisposable(_cancellationSubscription, _executionSubscription, _requestSubscription);

            CreateStateMachine();
        }
Ejemplo n.º 30
0
 public CurrencyPairViewModel(CurrencyPairStateDto currencyPairStateDto, IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService)
 {
     _currencyPairStateDto = currencyPairStateDto;
     _reactiveTrader = reactiveTrader;
     _concurrencyService = concurrencyService;
     Symbol = currencyPairStateDto.Symbol;
     Available = currencyPairStateDto.Enabled;
     Stale = currencyPairStateDto.Stale;
     CanModify = true;
 }
Ejemplo n.º 31
0
        public NotificationGenerator(IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService)
        {
            _reactiveTrader     = reactiveTrader;
            _concurrencyService = concurrencyService;

            NotificationsEnabled
            .Where(enabled => enabled)
            .Subscribe(_ => RegisterNotifications())
            .Add(_disposables);
        }
Ejemplo n.º 32
0
        public KeysController(ObservableCollection <Message> messages, IMessageProvider messageProvider, IConcurrencyService concurrencyService, ISettingsProvider settingsProvider)
        {
            this.messages           = messages;
            this.messageProvider    = messageProvider;
            this.concurrencyService = concurrencyService;

            var settings = settingsProvider.GetSettings <PopupSettings>();

            fadeOutDelay = TimeSpan.FromSeconds(settings.ItemFadeDelay);
        }
Ejemplo n.º 33
0
        public Rfq(IRfqService rfqService, IConcurrencyService concurrencyService)
        {
            _rfqService         = rfqService;
            _concurrencyService = concurrencyService;
            _stateMachine       = new StateMachine <RfqState, RfqEvent>(RfqState.Input);
            _rfqUpdateSubject   = new BehaviorSubject <RfqUpdate>(new RfqUpdate(RfqState.Input, null, null));
            _disposables        = new CompositeDisposable(_cancellationSubscription, _executionSubscription, _requestSubscription);

            CreateStateMachine();
        }
        public NotificationGenerator(IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService)
        {
            _reactiveTrader = reactiveTrader;
            _concurrencyService = concurrencyService;

            NotificationsEnabled
                .Where(enabled => enabled)
                .Subscribe(_ => RegisterNotifications())
                .Add(_disposables);
        }
Ejemplo n.º 35
0
 public CurrencyPairViewModel(CurrencyPairStateDto currencyPairStateDto, IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService)
 {
     _currencyPairStateDto = currencyPairStateDto;
     _reactiveTrader       = reactiveTrader;
     _concurrencyService   = concurrencyService;
     Symbol    = currencyPairStateDto.Symbol;
     Available = currencyPairStateDto.Enabled;
     Stale     = currencyPairStateDto.Stale;
     CanModify = true;
 }
 public ConnectivityStatusViewModel(
     IReactiveTrader reactiveTrader,
     IConcurrencyService concurrencyService)
 {
     reactiveTrader.ConnectionStatusStream
         .ObserveOn(concurrencyService.Dispatcher)
         .SubscribeOn(concurrencyService.TaskPool)
         .Subscribe(
         OnStatusChange,
         ex => log.Error("An error occurred within the connection status stream.", ex));
 }
Ejemplo n.º 37
0
        public BlotterViewModel(IReactiveTrader reactiveTrader,
                                Func<ITrade, bool, ITradeViewModel> tradeViewModelFactory,
                                IConcurrencyService concurrencyService)
        {
            _tradeRepository = reactiveTrader.TradeRepository;
            _tradeViewModelFactory = tradeViewModelFactory;
            _concurrencyService = concurrencyService;
            Trades = new ObservableCollection<ITradeViewModel>();

            LoadTrades();
        }
Ejemplo n.º 38
0
 public EntityInteractionDispatcher(
     ICollectionResolver collectionResolver,
     IRepositoryResolver repositoryResolver,
     IConcurrencyService concurrencyService,
     IButtonInteraction buttonInteraction)
 {
     _collectionResolver = collectionResolver;
     _repositoryResolver = repositoryResolver;
     _concurrencyService = concurrencyService;
     _buttonInteraction  = buttonInteraction;
 }
Ejemplo n.º 39
0
 /// <summary>
 /// Constructs a new instance of <see cref="DefaultProcessExecutor" />.
 /// </summary>
 /// <param name="concurrencyService">An implementation of <see cref="IConcurrencyService" />.</param>
 /// <param name="processRunner">An implementation of <see cref="IProcessRunner" />.</param>
 /// <param name="executionTokenGenerator">An implementation of <see cref="IExecutionTokenGenerator" /> used to generate execution tokens.</param>
 /// <param name="logger">The logger.</param>
 public DefaultProcessExecutor(
     IConcurrencyService concurrencyService,
     IProcessRunner processRunner,
     IExecutionTokenGenerator executionTokenGenerator,
     ILogger <DefaultProcessExecutor> logger)
 {
     _concurrencyService      = concurrencyService ?? throw new ArgumentNullException(nameof(concurrencyService));
     _processRunner           = processRunner ?? throw new ArgumentNullException(nameof(processRunner));
     _executionTokenGenerator = executionTokenGenerator ?? throw new ArgumentNullException(nameof(executionTokenGenerator));
     _logger = logger ?? throw new ArgumentNullException(nameof(logger));
 }
 public ConnectivityStatusViewModel(
     IReactiveTrader reactiveTrader,
     IConcurrencyService concurrencyService)
 {
     reactiveTrader.ConnectionStatusStream
     .ObserveOn(concurrencyService.Dispatcher)
     .SubscribeOn(concurrencyService.TaskPool)
     .Subscribe(
         OnStatusChange,
         ex => log.Error("An error occurred within the connection status stream.", ex));
 }
Ejemplo n.º 41
0
        public DialogService(IConcurrencyService concurrencyService)
        {
            mConcurrencyService = concurrencyService;

            var dialogViewModelSubject = new BehaviorSubject <object>(null);

            mPushDialogViewModel = dialogViewModelSubject.OnNext;

            mDialogActivationDisposable = new SerialDisposable();
            WhenDialogViewModelChanges  = dialogViewModelSubject.AsObservable()
                                          .Do(vm => mDialogActivationDisposable.Disposable = (vm as IActivatableViewModel)?.Activator.Activate());
        }
Ejemplo n.º 42
0
        public BlotterViewModel(IReactiveTrader reactiveTrader,
                                Func <ITrade, bool, ITradeViewModel> tradeViewModelFactory,
                                IConcurrencyService concurrencyService,
                                ILoggerFactory loggerFactory)
        {
            _tradeRepository       = reactiveTrader.TradeRepository;
            _tradeViewModelFactory = tradeViewModelFactory;
            _concurrencyService    = concurrencyService;
            Trades = new ObservableCollection <ITradeViewModel>();
            _log   = loggerFactory.Create(typeof(BlotterViewModel));

            LoadTrades();
        }
Ejemplo n.º 43
0
 public DataProviderResolver(
     ISetupResolver <CollectionSetup> collectionSetupResolver,
     IConcurrencyService concurrencyService,
     IRepositoryResolver repositoryResolver,
     IMediator mediator,
     IServiceProvider serviceProvider)
 {
     _collectionSetupResolver = collectionSetupResolver;
     _concurrencyService      = concurrencyService;
     _repositoryResolver      = repositoryResolver;
     _mediator        = mediator;
     _serviceProvider = serviceProvider;
 }
 public EntitiesInteractionDispatcher(
     ISetupResolver <ICollectionSetup> collectionResolver,
     IRepositoryResolver repositoryResolver,
     IConcurrencyService concurrencyService,
     IButtonInteraction buttonInteraction,
     IEditContextFactory editContextFactory)
 {
     _collectionResolver = collectionResolver;
     _repositoryResolver = repositoryResolver;
     _concurrencyService = concurrencyService;
     _buttonInteraction  = buttonInteraction;
     _editContextFactory = editContextFactory;
 }
Ejemplo n.º 45
0
        public BlotterViewModel(IReactiveTrader reactiveTrader,
                                Func<ITrade, bool, ITradeViewModel> tradeViewModelFactory,
                                IConcurrencyService concurrencyService,
                                ILoggerFactory loggerFactory)
        {
            _tradeRepository = reactiveTrader.TradeRepository;
            _tradeViewModelFactory = tradeViewModelFactory;
            _concurrencyService = concurrencyService;
            Trades = new ObservableCollection<ITradeViewModel>();
            _log = loggerFactory.Create(typeof (BlotterViewModel));

            LoadTrades();
        }
        public ConnectivityStatusViewModel(IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService)
        {
            _priceLatencyRecorder = reactiveTrader.PriceLatencyRecorder;
            reactiveTrader.ConnectionStatusStream
                .ObserveOn(concurrencyService.Dispatcher)
                .SubscribeOn(concurrencyService.ThreadPool)
                .Subscribe(
                OnStatusChange,
                ex => Log.Error("An error occurred within the connection status stream.", ex));

            Observable
                .Interval(StatsFrequency, concurrencyService.Dispatcher)
                .Subscribe(OnTimerTick);
        }
Ejemplo n.º 47
0
        public StatusFragment(IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService)
        {
            _reactiveTrader = reactiveTrader;

            _disposables.Add(
                _reactiveTrader.ConnectionStatusStream
                    .SubscribeOn(concurrencyService.TaskPool)
                    .ObserveOn(concurrencyService.Dispatcher)
                    .Subscribe(OnStatusChange));

            _disposables.Add(
                Observable.Interval(TimeSpan.FromSeconds(1), concurrencyService.TaskPool)
                    .ObserveOn(concurrencyService.Dispatcher)
                    .Subscribe(_ => OnTimer()));
        }
 public TickersViewModel(IReactiveTrader reactiveTrader,
                         IConcurrencyService concurrencyService,
     TickerViewModelFactory tickerViewModelFactory)
 {
     Tickers = new ObservableCollection<TickerViewModel>();
     Tickers.Add(tickerViewModelFactory.Create("Yahoo"));
     Tickers.Add(tickerViewModelFactory.Create("Google"));
     Tickers.Add(tickerViewModelFactory.Create("Apple"));
     Tickers.Add(tickerViewModelFactory.Create("Facebook"));
     Tickers.Add(tickerViewModelFactory.Create("Microsoft"));
     Tickers.Add(tickerViewModelFactory.Create("Twitter"));
     this.tickerRepository = reactiveTrader.TickerRepository;
     this.concurrencyService = concurrencyService;
     LoadTrades();
 }
Ejemplo n.º 49
0
        public MainViewModel(IReactiveTrader reactiveTrader, 
            Func<CurrencyPairStateDto, ICurrencyPairViewModel> ccyViewModelFactory,
            IUserProvider userProvider,
            IConfigurationProvider configurationProvider,
            IConcurrencyService concurrencyService)
        {
            _reactiveTrader = reactiveTrader;
            _ccyViewModelFactory = ccyViewModelFactory;
            _userProvider = userProvider;
            _configurationProvider = configurationProvider;
            _concurrencyService = concurrencyService;

            RefreshCommand = new DelegateCommand(RefreshData);
            CurrencyPairs = new ObservableCollection<ICurrencyPairViewModel>();

            ObserveThroughputs();
        }
Ejemplo n.º 50
0
		public LogViewController (IConcurrencyService concurrencyService, ILogSource logSource)
		{
			_logSource = logSource;
			_concurrencyService = concurrencyService;

			Title = "Logs";
			TabBarItem.Image = UIImage.FromBundle ("adaptive");

			_logSource.LogSource
				.ObserveOn(_concurrencyService.Dispatcher)
				.Subscribe ((string message) => {
					if (!_isInitialised)
						_messages.Add (message);
					else
						OnMessage(message);
			});
		}
Ejemplo n.º 51
0
		public StatusViewController (IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService) : base ("StatusViewController", null)
		{
			_reactiveTrader = reactiveTrader;
			_concurrencyService = concurrencyService;

			Title = "Status";
			TabBarItem.Image = UIImage.FromBundle ("tab_status");

			_disposables.Add (
				_reactiveTrader.ConnectionStatusStream
					.SubscribeOn (_concurrencyService.TaskPool)
					.ObserveOn (_concurrencyService.Dispatcher)
					.Subscribe (OnStatusChange));

			_disposables.Add (
				Observable.Interval (TimeSpan.FromSeconds(1), _concurrencyService.TaskPool)
					.ObserveOn (_concurrencyService.Dispatcher)
					.Subscribe(_ => OnTimer()));

		}
		public PriceTilesViewController (IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService) 
			: base(UITableViewStyle.Plain)
		{
			this._concurrencyService = concurrencyService;
			this._reactiveTrader = reactiveTrader;

			Title = "Prices";
			TabBarItem.Image = UIImage.FromBundle ("tab_prices");

			_model = new PriceTilesModel (_reactiveTrader, _concurrencyService);

			_model.ActiveCurrencyPairs.CollectionChanged += (sender, e) => {
				foreach (var model in e.NewItems.Cast<PriceTileModel>()) {
					model.OnChanged
						.Subscribe (OnItemChanged);
				}
				if (IsViewLoaded) {
					TableView.ReloadData ();
				}
			};
			_model.Initialise ();

		}
Ejemplo n.º 53
0
        public SpotTileAdapter(ObservableCollection<ISpotTileViewModel> spotTileCollection, IConcurrencyService concurrencyService)
        {
            _spotTileCollection = spotTileCollection;
            _concurrencyService = concurrencyService;

            _collectionChangedSubscription = _spotTileCollection
                .ObserveCollection()
                .Throttle(TimeSpan.FromMilliseconds(10))
                .ObserveOn(_concurrencyService.Dispatcher)
                .Subscribe(async eventArgs =>
                {
                    switch (eventArgs.Action)
                    {
                        case NotifyCollectionChangedAction.Add:
                            
                            NotifyItemRangeInserted(eventArgs.NewStartingIndex, eventArgs.NewItems.Count);
                            break;

                        case NotifyCollectionChangedAction.Remove:

                            NotifyItemRangeRemoved(eventArgs.OldStartingIndex, eventArgs.OldItems.Count);
                            break;

                        default:

                            _allSubscriptions.Clear();
                            NotifyDataSetChanged();
                            break;
                    }

					if (_animate)
					{
						await Task.Delay(3000);
						_animate = false;
					}
                });
        }
Ejemplo n.º 54
0
 public KeysController(ObservableCollection<Message> messages, IMessageProvider messageProvider, IConcurrencyService concurrencyService)
 {
     this.messages = messages;
     this.messageProvider = messageProvider;
     this.concurrencyService = concurrencyService;
 }
Ejemplo n.º 55
0
		public PriceTilesModel (IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService)
		{
			this._concurrencyService = concurrencyService;
			this._reactiveTrader = reactiveTrader;
		}
Ejemplo n.º 56
0
        public void Bind(ISpotTileViewModel spotTileViewModel, IConcurrencyService concurrencyService)
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            _allSubscriptions.Clear();

            int i = 0;

            concurrencyService.Dispatcher.Schedule(() =>
            {
                if (spotTileViewModel.State == TileState.Affirmation)
                {
                    spotTileViewModel.DismissAffirmation();
                }

                Reset();
                CurrencyPairLabel.Text = spotTileViewModel.Pricing.Symbol;
                BidButton.SetDataContext(spotTileViewModel.Pricing.Bid);
                AskButton.SetDataContext(spotTileViewModel.Pricing.Ask);
                SetHistoricPrices(spotTileViewModel.Pricing.HistoricalMid);
            });

            _allSubscriptions.Add(spotTileViewModel.Pricing.Bid
                .ObserveProperty(vm => vm.IsExecuting, false)
                .ObserveOn(concurrencyService.Dispatcher)
                .Subscribe(s => AskButton.SetEnabledOverride(!s)));

            _allSubscriptions.Add(spotTileViewModel.Pricing.Ask
			                      .ObserveProperty(vm => vm.IsExecuting, false)
                .ObserveOn(concurrencyService.Dispatcher)
                .Subscribe(s => BidButton.SetEnabledOverride(!s)));

			_allSubscriptions.Add(spotTileViewModel.Pricing.ObserveProperty(vm => vm.Spread, false)
                .ObserveOn(concurrencyService.Dispatcher)
                .Subscribe(s => SpreadLabel.Text = s));

			_allSubscriptions.Add(spotTileViewModel.Pricing.ObserveProperty(vm => vm.DealtCurrency, false)
                .ObserveOn(concurrencyService.Dispatcher)
                .Subscribe(s => DealtCurrencyLabel.Text = s));

			_allSubscriptions.Add(spotTileViewModel.Pricing.ObserveProperty(vm => vm.SpotDate, false)
                .ObserveOn(concurrencyService.Dispatcher)
                .Subscribe(s => SpotDateLabel.Text = s));

			_allSubscriptions.Add(spotTileViewModel.Pricing.ObserveProperty(vm => vm.Mid, false)
                .ObserveOn(concurrencyService.Dispatcher)
                .Subscribe(AddPrice));

            _allSubscriptions.Add(spotTileViewModel.Pricing.ObserveProperty(vm => vm.IsStale)
                .ObserveOn(concurrencyService.Dispatcher)
                .Subscribe(SetIsStale));

            // two way bind the notional
            _allSubscriptions.Add(spotTileViewModel.Pricing.ObserveProperty(vm => vm.Notional, true)
                .Where(n => n != NotionalTextBox.Text)
                .ObserveOn(concurrencyService.Dispatcher)
                .Subscribe(s => NotionalTextBox.Text = s));

            _allSubscriptions.Add(NotionalTextBox
                .TextChangedStream()
                .Where(_ => spotTileViewModel.Pricing.Notional != NotionalTextBox.Text)
                .ObserveOn(concurrencyService.Dispatcher)
                .Subscribe(_ =>
                {
                    spotTileViewModel.Pricing.Notional = NotionalTextBox.Text;
                }));

            _allSubscriptions.Add(spotTileViewModel.Pricing.ObserveProperty(vm => vm.Movement, true)
                .ObserveOn(concurrencyService.Dispatcher)
                .Subscribe(m =>
                {
                    UpArrow.Visibility = m == PriceMovement.Up ? ViewStates.Visible : ViewStates.Invisible;
                    DownArrow.Visibility = m == PriceMovement.Down ? ViewStates.Visible : ViewStates.Invisible;
                }));

            _allSubscriptions.Add(spotTileViewModel.ObserveProperty(vm => vm.State, true)
                .Where(m => m == TileState.Affirmation)
                .SubscribeOn(concurrencyService.TaskPool)
                .Subscribe(async m =>
                {
                    try
                    {
                        _cancelAnimationSource = new CancellationTokenSource();
                        ShowAffirmation(spotTileViewModel.Affirmation);
                        await Task.Delay(4000, _cancelAnimationSource.Token);
                    }
                    catch (TaskCanceledException)
                    {
                        /* Animation was cancelled */
                    }
                    finally
                    {
                        spotTileViewModel.DismissAffirmation();
                    }
                }));

            _allSubscriptions.Add(spotTileViewModel.ObserveProperty(vm => vm.State, true)
                .Where(m => m == TileState.Pricing)
                .SubscribeOn(concurrencyService.TaskPool)
                .Subscribe(_ => ShowPricing()));
        }
Ejemplo n.º 57
0
 public PricesListFragment(IShellViewModel shellViewModel, IConcurrencyService concurrencyService)
 {
     _shellViewModel = shellViewModel;
     _concurrencyService = concurrencyService;
 }
 public ExecutionRepository(IExecutionServiceClient executionServiceClient, ITradeFactory tradeFactory, IConcurrencyService concurrencyService)
 {
     _executionServiceClient = executionServiceClient;
     _tradeFactory = tradeFactory;
     _concurrencyService = concurrencyService;
 }
Ejemplo n.º 59
0
		public TradeTilesModel (IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService)
		{
			_reactiveTrader = reactiveTrader;
			_concurrencyService = concurrencyService;
		}