public void Initialise() { _source1 = new SourceCache<Person, string>(p => p.Name); _source2 = new SourceCache<Person, string>(p => p.Name); _results = _source1.Connect().And(_source2.Connect()).AsAggregator(); }
public void MyTestInitialize() { _scheduler = new TestScheduler(); _source = new SourceCache<Person, string>(p => p.Key); _results = _source.Connect().Batch(TimeSpan.FromMinutes(1), _scheduler).AsAggregator(); }
public void Initialise() { _source = new SourceCache<ObjectWithObservable, int>(p => p.Id); _observable = _source.Connect() .TrueForAll(o => o.Observable.StartWith(o.Value), (obj, invoked) => invoked); }
public void Initialise() { _source = new SourceCache<Person, string>(p => p.Name); _controller = new GroupController(); _grouped = _source.Connect(p => _grouper(p)!= AgeBracket.Pensioner) .Group(_grouper, _controller).AsObservableCache(); }
public TradeService(ILogger logger,TradeGenerator tradeGenerator, ISchedulerProvider schedulerProvider) { _logger = logger; _tradeGenerator = tradeGenerator; _schedulerProvider = schedulerProvider; //construct a cache specifying that the primary key is Trade.Id _tradesSource = new SourceCache<Trade, long>(trade => trade.Id); //call AsObservableCache() to hide the update methods as we are exposing the cache _all = _tradesSource.AsObservableCache(); //create a derived cache _live = _tradesSource.Connect(trade => trade.Status == TradeStatus.Live).AsObservableCache(); //code to emulate an external trade provider var tradeLoader = GenerateTradesAndMaintainCache(); //expire closed items from the cache ro avoid unbounded data var expirer = _tradesSource .ExpireAfter(t => t.Status == TradeStatus.Closed ? TimeSpan.FromMinutes(1) : (TimeSpan?)null,TimeSpan.FromMinutes(1),schedulerProvider.TaskPool) .Subscribe(x=>_logger.Info("{0} filled trades have been removed from memory",x.Count())); //log changes var loggerWriter = LogChanges(); _cleanup = new CompositeDisposable(_all, _tradesSource, tradeLoader, loggerWriter, expirer); }
public void MyTestInitialize() { _pausingSubject = new Subject<bool>(); _scheduler = new TestScheduler(); _source = new SourceCache<Person, string>(p => p.Key); _results = _source.Connect().BatchIf(_pausingSubject, _scheduler).AsAggregator(); }
public void Initialise() { _source =new SourceCache<Person, string>(p=>p.Name); var pTransform = _source.Connect().Transform(_transformFactory); _results = new ChangeSetAggregator<PersonWithGender, string>(pTransform); }
public void SetUp() { _source = new SourceCache<Person, string>(p => p.Key); _results = new ChangeSetAggregator<Person, string> ( _source.Connect().IgnoreUpdateWhen((current,previous)=>current == previous) ); }
public void Initialise() { _source = new SourceCache<PersonWithRelations, string>(p=>p.Key); _results = _source.Connect().TransformMany(p => p.Relations.RecursiveSelect(r => r.Relations), p => p.Name) .IgnoreUpdateWhen((current, previous) => current.Name == previous.Name) .AsAggregator(); }
public void MyTestInitialize() { _scheduler = new TestScheduler(); _cache = new SourceCache<Person, string>(p=>p.Key); _results = new ChangeSetAggregator<Person, string>(_cache.Connect()); _remover = _cache.ExpireAfter(p=>TimeSpan.FromMilliseconds(100), _scheduler).Subscribe(); }
public void MyTestInitialize() { _source = new SourceCache<Person, string>(p => p.Key); _results = new ChangeSetAggregator<Person, string> ( _source.Connect().IncludeUpdateWhen((current, previous) => current != previous) ); }
public void Initialise() { _source = new SourceCache<Person, string>(p=>p.Name); _errors = new List<Error<Person, string>>(); var safeTransform = _source.Connect().TransformSafe(_transformFactory, error => _errors.Add(error)); _results = new ChangeSetAggregator<PersonWithGender, string>(safeTransform); }
public void Initialise() { _scheduler = new TestScheduler(); _source =new SourceCache<Person, string>(p=>p.Key); _sizeLimiter = _source.LimitSizeTo(10,_scheduler).FinallySafe(()=>Console.WriteLine()).Subscribe(); _results = _source.Connect().AsAggregator(); }
public UpdateTradesService(ISourceCache<Trade, long> myTrades, ISourceCache<Quote, string> quotes, ISourceCache<BalancePerClient, long> clientBalances, ISourceCache<CurPairPositionPerClient, string> curPairPositionPerClient, ISourceCache<CurPositionPerClient, string> curPositionPerClient) : base(myTrades, quotes, clientBalances, curPairPositionPerClient, curPositionPerClient) { }
public PositionPerCurrencyPairCalculatorService(ISourceCache<Trade, long> myTrades, ISourceCache<Quote, string> quotes, ISourceCache<BalancePerClient, long> clientBalances, ISourceCache<CurPairPositionPerClient, string> curPairPositionPerClient, ISourceCache<CurPositionPerClient, string> curPositionPerClient ) : base(myTrades, quotes, clientBalances, curPairPositionPerClient, curPositionPerClient) { }
public RealTimeModel(ISchedulerProvider schProvider, IBikeService bikeService) { _schProvider = schProvider; _bikeService = bikeService; _bikeDataSource = new SourceCache<StationDto, string>(bike => bike.Name); _all = _bikeDataSource.AsObservableCache(); var data = GenerateRealTimeData(); _cleanup = new CompositeDisposable(_all, _bikeDataSource, data); }
public void SetUp() { _collection = new ObservableCollectionExtended<Person>(); _source = new SourceCache<Person, string>(p => p.Name); _binder = _source.Connect() .Sort(_comparer,resetThreshold:25) .Bind(_collection) .Subscribe(); }
public void Initialise() { _source = new SourceCache<SubscribeableObject, int>(p=>p.Id); _results = new ChangeSetAggregator<SubscribeableObject, int>( _source.Connect().SubscribeMany(subscribeable => { subscribeable.Subscribe(); return Disposable.Create(subscribeable.UnSubscribe); })); }
public void Initialise() { _comparer = SortExpressionComparer<Person>.Ascending(p => p.Name).ThenByAscending(p => p.Age); _cache = new SourceCache<Person, string>(p => p.Name); _sortController = new SortController<Person>(_comparer); _results = new SortedChangeSetAggregator<Person, string> ( _cache.Connect().Sort(_sortController) ); }
public void Initialise() { _sortController = new SortController<Person>(_originalComparer); _source = new SourceCache<Person, string>(p => p.Key); _pageController = new PageController(new PageRequest(1, 25)); _aggregators = new PagedChangeSetAggregator<Person, string> ( _source.Connect() .Sort(_sortController) .Page(_pageController) ); }
public void Initialise() { _comparer = SortExpressionComparer<Person>.Ascending(p => p.Name).ThenByAscending(p => p.Age); _source = new SourceCache<Person, string>(p=>p.Key); _pageController = new PageController(new PageRequest(1,25)); _aggregators = new PagedChangeSetAggregator<Person, string> ( _source.Connect() .Sort(_comparer) .Page(_pageController) ); }
// protected object curPositionPerClient_Lock; public BaseService(ISourceCache<Trade, long> myTrades, ISourceCache<Quote, string> quotes, ISourceCache<BalancePerClient, long> clientBalances, ISourceCache<CurPairPositionPerClient, string> curPairPositionPerClient, ISourceCache<CurPositionPerClient, string> curPositionPerClient // object CurPositionPerClient_Lock ) { this.myTrades = myTrades; this.quotes = quotes; this.clientBalances = clientBalances; this.curPairPositionPerClient = curPairPositionPerClient; this.curPositionPerClient = curPositionPerClient; //this.curPositionPerClient_Lock = CurPositionPerClient_Lock; this.logger = LogManager.GetLogger("MarginTrader"); }
public TradeService(ILogger logger,TradeGenerator tradeGenerator, ISchedulerProvider schedulerProvider) { _logger = logger; _tradeGenerator = tradeGenerator; _schedulerProvider = schedulerProvider; //construct a cache specifying that the unique key is Trade.Id _tradesSource = new SourceCache<Trade, long>(trade => trade.Id); //call AsObservableCache() to hide the update methods as we are exposing the cache _tradesCache = _tradesSource.AsObservableCache(); //code to emulate an external trade provider var tradeLoader = GenerateTradesAndMaintainCache(); _cleanup = new CompositeDisposable(_tradesCache, _tradesSource, tradeLoader); }
static void Main(string[] args) { XmlConfigurator.Configure(); quotes = new SourceCache<Quote, string>(quote => quote.Pair); myTrades = new SourceCache<Trade, long>(trade => trade.Id); clientBalances = new SourceCache<BalancePerClient, long>(Balance => Balance.ClientID); curPairPositionPerClient = new SourceCache<CurPairPositionPerClient, string>(CurPairPositionPerClient => CurPairPositionPerClient.ClientPair); curPositionPerClient = new SourceCache<CurPositionPerClient, string>(CurPositionPerClient => CurPositionPerClient.ClientIdCur); myTrades_Locker = new object(); CurPositionPerClient_Locker = new object(); // services Initialization IQuoteExtractorService quoteExtractor = new QuoteExtractorService(myTrades, quotes, clientBalances, curPairPositionPerClient, curPositionPerClient); new Thread(quoteExtractor.ExtractData).Start(); ILogPrinterService logPrinterService = new LogPrinterService(myTrades, quotes, clientBalances, curPairPositionPerClient, curPositionPerClient); logPrinterService.PrintClientBalances(); logPrinterService.PrintcurPairPositionPerClient(); logPrinterService.PrintmyTrades(); logPrinterService.PrintCurPositionPerClient(); IStopOutExecutorService stopOutExecutorService = new StopOutExecutorService(myTrades, quotes, clientBalances, curPairPositionPerClient, curPositionPerClient); stopOutExecutorService.ManageStopOuts(); IPositionPerCurrencyPairCalculatorService positionPerCurrencyPairCalculatorService = new PositionPerCurrencyPairCalculatorService(myTrades, quotes, clientBalances, curPairPositionPerClient, curPositionPerClient); positionPerCurrencyPairCalculatorService.CalculatePosistionPerCurrencyPairPerCustomer(); IPositionPerCurrencyCalculatorService positionPerCurrencyCalculatorService = new PositionPerCurrencyCalculatorService(myTrades, quotes, clientBalances, curPairPositionPerClient, curPositionPerClient); positionPerCurrencyCalculatorService.CalculatePosistionPerCurrencyPerCustomer(); IMarginCalculatorService marginCalculatorService = new MarginCalculatorService(myTrades, quotes, clientBalances, curPairPositionPerClient, curPositionPerClient); marginCalculatorService.CalculateRequiredMargin(); IPAndLUpdaterService pAndLUpdaterService = new PAndLUpdaterService(myTrades, quotes, clientBalances, curPairPositionPerClient, curPositionPerClient); pAndLUpdaterService.UpdatePandLPerClient(); ICurrencyPositionPerClientUpdaterService currencyPositionPerClientUpdaterService = new CurrencyPositionPerClientUpdaterService(myTrades, quotes, clientBalances, curPairPositionPerClient, curPositionPerClient); currencyPositionPerClientUpdaterService.UpdateAllCurrenciesPositions(); IUpdateTradesService updateTradesService = new UpdateTradesService(myTrades, quotes, clientBalances, curPairPositionPerClient, curPositionPerClient); updateTradesService.UpdateAllTradesAndQuotes(); }
public void SetUp() { _scheduler = new TestScheduler(); _source = new SourceCache<Person, string>(p => p.Key); _watcher = _source.Connect().AsWatcher(_scheduler); _results = new ChangeSetAggregator<SelfObservingPerson, string> ( _source.Connect() .Transform(p => new SelfObservingPerson(_watcher.Watch(p.Key).Select(w => w.Current))) .DisposeMany() ); _cleanUp = Disposable.Create(() => { _results.Dispose(); _source.Dispose(); _watcher.Dispose(); }); }
public TradeService(ILogger logger,TradeGenerator tradeGenerator, ISchedulerProvider schedulerProvider) { _logger = logger; _tradeGenerator = tradeGenerator; _schedulerProvider = schedulerProvider; //construct a cache specifying that the primary key is Trade.Id _tradesSource = new SourceCache<Trade, long>(trade => trade.Id); //call AsObservableCache() to hide the update methods as we are exposing the cache _all = _tradesSource.AsObservableCache(); //create a child cache _live = _tradesSource.Connect(trade => trade.Status == TradeStatus.Live).AsObservableCache(); //code to emulate an external trade provider var tradeLoader = GenerateTradesAndMaintainCache(); //log changes var loggerWriter = LogChanges(); _cleanup = new CompositeDisposable(_all, _tradesSource, tradeLoader, loggerWriter); }
public DisposeManyFixture() { _source = new SourceCache <DisposableObject, int>(p => p.Id); _results = new ChangeSetAggregator <DisposableObject, int>(_source.Connect().DisposeMany()); }
public void MyTestInitialize() { _scheduler = new TestScheduler(); _source = new SourceCache <Person, string>(p => p.Key); _results = _source.Connect().Batch(TimeSpan.FromMinutes(1), _scheduler).AsAggregator(); }
public void MyTestInitialize() { _scheduler = new TestScheduler(); _source = new SourceCache<Person, string>(p => p.Key); _results = _source.Connect().AsAggregator(); }
public FilterFixture() { _source = new SourceCache <Person, string>(p => p.Name); _results = _source.Connect(p => p.Age > 20).AsAggregator(); }
public void Initialise() { _source = new SourceCache <Person, string>(p => p.Key); _results = new ChangeSetAggregator <Person, string>(_source.Connect().Filter(p => p.Age > 20, new ParallelisationOptions(ParallelType.Ordered))); }
public void Initialise() { _source1 = new SourceCache <Person, string>(p => p.Name); _source2 = new SourceCache <Person, string>(p => p.Name); _results = _source1.Connect().And(_source2.Connect()).AsAggregator(); }
public BatchIfWithTimeoutFixture() { _scheduler = new TestScheduler(); _source = new SourceCache <Person, string>(p => p.Key); }
public MergeManyWithKeyOverloadFixture() { _source = new SourceCache <ObjectWithObservable, int>(p => p.Id); }
public void Initialise() { _source = new SourceCache <ObjectWithObservable, int>(p => p.Id); }
public FilterControllerFixture() { _source = new SourceCache <Person, string>(p => p.Key); _filter = new BehaviorSubject <Func <Person, bool> >(p => p.Age > 20); _results = new ChangeSetAggregator <Person, string>(_source.Connect().Filter(_filter)); }
public void Initialise() { _source = new SourceCache <Person, string>(p => p.Key); _filter = new FilterController <Person>(p => p.Age > 20); _results = new ChangeSetAggregator <Person, string>(_source.Connect(_filter)); }
public GroupFromDistinctFixture() { _personCache = new SourceCache <Person, string>(p => p.Key); _employmentCache = new SourceCache <PersonEmployment, PersonEmpKey>(e => e.Key); }
public void Initialise() { _source = new SourceCache <Person, string>(p => p.Name); _results = _source.Connect(p => p.Age > 20).AsAggregator(); }
public void Initialise() { _source = new SourceCache<ObjectWithObservable, int>(p => p.Id); _observable = _source.Connect().TrueForAny(o => o.Observable.StartWith(o.Value), o => o == true); }
protected XOrFixtureBase() { _source1 = new SourceCache <Person, string>(p => p.Name); _source2 = new SourceCache <Person, string>(p => p.Name); _results = CreateObservable().AsAggregator(); }
public void Initialise() { _targetSource = new SourceCache <Person, string>(p => p.Name); _exceptSource = new SourceCache <Person, string>(p => p.Name); _results = _targetSource.Connect().Except(_exceptSource.Connect()).AsAggregator(); }
public SwitchFixture() { _source = new SourceCache <Person, string>(p => p.Name); _switchable = new BehaviorSubject <ISourceCache <Person, string> >(_source); _results = _switchable.Switch().AsAggregator(); }
public static void SetTo <V, K>(this ISourceCache <V, K> cache, IEnumerable <V> items) where K : notnull { cache.Clear(); cache.AddOrUpdate(items); }
private SSBakery.Models.CatalogCategory UpdateCategoryCache(CatalogObject catalogObject, ISourceCache <SSBakery.Models.CatalogCategory, string> categoryCache) { var lookupResult = categoryCache.Lookup(catalogObject.Id); var isNew = !lookupResult.HasValue; var category = isNew ? null : lookupResult.Value; if (isNew) { category = MapDtoToCategory(catalogObject); categoryCache.AddOrUpdate(category); } else { category.Name = catalogObject.CategoryData.Name; } return(category); }
public GroupImmutableFixture() { _source = new SourceCache <Person, string>(p => p.Name); _results = _source.Connect().GroupWithImmutableState(p => p.Age).AsAggregator(); }
public BatchIfWithTimeOutFixture() { _scheduler = new TestScheduler(); _source = new SourceCache <Person, string>(p => p.Key); _results = _source.Connect().BatchIf(_pausingSubject, TimeSpan.FromMinutes(1), _scheduler).AsAggregator(); }
public ExpireAfterFixture() { _scheduler = new TestScheduler(); _source = new SourceCache <Person, string>(p => p.Key); _results = _source.Connect().AsAggregator(); }
public SourceCacheFixture() { _source = new SourceCache <Person, string>(p => p.Key); _results = _source.Connect().AsAggregator(); }
public ObservableCollectionBindCacheFixture() { _source = new SourceCache <Person, string>(p => p.Name); _binder = _source.Connect().Bind(_collection).Subscribe(); }
public void Initialise() { _source = new SourceCache<ObjectWithObservable, int>(p => p.Id); }
public void MyTestInitialize() { _source = new SourceCache <Person, string>(p => p.Key); }
public void SetStream() { _personCache = new SourceCache <Person, string>(p => p.Key); _employmentCache = new SourceCache <PersonEmployment, PersonEmpKey>(e => e.Key); }
public BillsViewModel( IDialogService dialogService , IBillingService billingService , BillsFiltersViewModel billsFilterViewModel //, Func<AddBillViewModel> addBillViewModelFactoryMethod //, Func<BillDto, EditBillViewModel> editBillViewModelFactoryMethod ) { this._dialogService = dialogService ?? throw new ArgumentNullException(nameof(dialogService)); this._billingService = billingService ?? throw new ArgumentNullException(nameof(billingService)); this.BillsFilterViewModel = billsFilterViewModel ?? throw new ArgumentNullException(nameof(billsFilterViewModel)); //this._addBillViewModelFactoryMethod = addBillViewModelFactoryMethod ?? throw new ArgumentNullException(nameof(addBillViewModelFactoryMethod)); //this._editBillViewModelFactoryMethod = editBillViewModelFactoryMethod ?? throw new ArgumentNullException(nameof(editBillViewModelFactoryMethod)); this._billsSubscription = new SerialDisposable().DisposeWith(this._disposables); this._billsSourceCache = new SourceCache <BillDto, long>(x => x.Id).DisposeWith(this._disposables); this.WhenSelectionChanged = this.WhenAnyValue(x => x.SelectedBillViewModel).DistinctUntilChanged(); this.WhenHasSelectionChanged = this.WhenSelectionChanged.Select(x => x != null).DistinctUntilChanged(); this.LoadBills = ReactiveCommand.Create( () => { this._billsSourceCache.Edit(async updater => { updater.Clear(); var items = await this._billingService.Bills.GetAsync(this.BillsFilterViewModel.Criteria).ConfigureAwait(false); updater.AddOrUpdate(items); }); }) .DisposeWith(this._disposables); _ = this.LoadBills.ThrownExceptions .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(ex => Debug.WriteLine(ex)) .DisposeWith(this._disposables); this.BillsFilterViewModel.WhenCriteriaChanged //.ObserveOn(RxApp.TaskpoolScheduler) //.SubscribeOn(RxApp.MainThreadScheduler) .Select(_ => Unit.Default) .InvokeCommand(this /*, x => x*/.LoadBills) .DisposeWith(this._disposables); //this.ShowAddBillView = ReactiveCommand.CreateFromTask( // () => this._dialogService.ShowDialogAsync(this._addBillViewModelFactoryMethod())) // .DisposeWith(this._disposables); //_ = this.ShowAddBillView.ThrownExceptions // .ObserveOn(RxApp.MainThreadScheduler) // .Subscribe(ex => Debug.WriteLine(ex)) // .DisposeWith(this._disposables); this.RemoveBill = ReactiveCommand.CreateFromTask( async(BillViewModel billViewModel) => { if (billViewModel == null) { // TODO: should throw? return; } if (this.SelectedBillViewModel == billViewModel) { this.SelectedBillViewModel = null; } // TODO: handle if removed failed var wasRemoved = await this._billingService.Bills.RemoveAsync(billViewModel.Id).ConfigureAwait(false); } , this.WhenHasSelectionChanged) .DisposeWith(this._disposables); _ = this.RemoveBill.ThrownExceptions .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(ex => Debug.WriteLine(ex)) .DisposeWith(this._disposables); //this.ShowEditBillView = ReactiveCommand.CreateFromTask( // async (BillViewModel billViewModel) => // { // if (billViewModel == null) // { // // TODO: throw or log, cause this shouldnt happen // return; // } // var editBillVM = this._editBillViewModelFactoryMethod.Invoke(billViewModel.BillDto); // await this._dialogService.ShowDialogAsync(editBillVM); // } // , this.WhenHasSelectionChanged) // .DisposeWith(this._disposables); ; //_ = this.ShowEditBillView.ThrownExceptions // .ObserveOn(RxApp.MainThreadScheduler) // .Subscribe(ex => Debug.WriteLine(ex)) // .DisposeWith(this._disposables); }
public void SetStream() { _personFeeder = new SourceCache<Person, string>(p=>p.Key); _employmentFeeder = new SourceCache<PersonEmployment, PersonEmpKey>(e=>e.Key); }
protected ExceptFixtureBase() { _targetSource = new SourceCache <Person, string>(p => p.Name); _exceptSource = new SourceCache <Person, string>(p => p.Name); _results = CreateObservable().AsAggregator(); }
public void MyTestInitialize() { _source = new SourceCache <Person, string>(p => p.Key); _results = _source.Connect().AsAggregator(); }
public void SetUp() { _collection = new ObservableCollectionExtended <Person>(); _source = new SourceCache <Person, string>(p => p.Name); _cloner = _source.Connect().Clone(_collection).Subscribe(); }