public PositionsStorageProxy(IPositionsStorage positionsStorage, Dispatcher dispatcher, ProxiesFactory proxiesFactory) { Contract.Requires(positionsStorage != null); Contract.Requires(dispatcher != null); Contract.Requires(proxiesFactory != null); this.dispatcher = dispatcher; this.proxiesFactory = proxiesFactory; this.positionAddedEvent = dispatcher.RegisterEvent(); positionsStorage.PositionAdded += this.OnPositionAdded; this.positions = positionsStorage.Positions.Select(proxiesFactory.CreatePositionProxy).ToList(); }
public Client(IApiObjectsFactory objectsFactory, IAccountsStorage accountsStorage, Dispatcher dispatcher, IConnection connection, CancellationTokenSource internalCancelationTokenSource) { CodeContract.Requires(objectsFactory != null); CodeContract.Requires(accountsStorage != null); CodeContract.Requires(dispatcher != null); CodeContract.Requires(connection != null); CodeContract.Requires(accountsStorage.Accounts.Count() != 0); this.objectsFactory = objectsFactory; this.accountsStorage = accountsStorage; this.dispatcher = dispatcher; this.internalCancelationTokenSource = internalCancelationTokenSource; this.accountChangedEvent = dispatcher.RegisterEvent(); connection.OnDisconnect += this.ConnectionOnOnDisconnect; }