Ejemplo n.º 1
0
        public EmulationService(StrategyContainer strategy)
        {
            if (strategy == null)
            {
                throw new ArgumentNullException(nameof(strategy));
            }

            Strategy   = strategy;
            Strategies = new[] { strategy }.ToEx(1);

            var storageRegistry = new StudioStorageRegistry {
                MarketDataSettings = Strategy.MarketDataSettings
            };

            _basketEmulation = new BatchEmulation(new StudioSecurityProvider(), new Portfolio[0], storageRegistry);

            _basketEmulation.StateChanged    += BasketEmulationOnStateChanged;
            _basketEmulation.ProgressChanged += (curr, total) =>
            {
                Progress = total;

                _basketEmulation
                .BatchStrategies
                .OfType <StrategyContainer>()
                .ForEach(s => ProgressChanged.SafeInvoke((StrategyContainer)s.Strategy, curr));
            };

            ConfigManager.GetService <LogManager>().Sources.Add(EmulationConnector);

            EmulationConnector.HistoryMessageAdapter.StorageRegistry = storageRegistry;

            CanStart = true;
        }
Ejemplo n.º 2
0
        private void OnProgressChanged(TProgress progress)
        {
            if (_reportProgress != null)
            {
                _reportProgress(progress);
            }

            var action = new Action(() => ProgressChanged.SafeInvoke(this, new CommandProgressChangedEventArgs <TProgress>(progress)));

            AutoDispatchIfRequired(action);
        }
Ejemplo n.º 3
0
 private void OnProgressChanged(StreamCopyProgressEventArgs args)
 {
     ProgressChanged.SafeInvoke(this, args);
 }