Ejemplo n.º 1
0
        private void AddRow(string groupVal, int value, IWritableReactiveTable table1, string GroupColumnId, string ValueColumnId)
        {
            var row1 = table1.AddRow();

            table1.SetValue(GroupColumnId, row1, groupVal);
            table1.SetValue(ValueColumnId, row1, value);
        }
        private static void AddPerson(IWritableReactiveTable people, int id, string name)
        {
            var rowIndex = people.AddRow();

            people.SetValue(PersonColumns.IdColumn, rowIndex, PersonIdOffset + id);
            people.SetValue(PersonColumns.NameColumn, rowIndex, name);
        }
        private static void AddAccount(IWritableReactiveTable accountsWire, int accountId, int personId, decimal balance)
        {
            var rowId = accountsWire.AddRow();

            accountsWire.SetValue(AccountColumns.IdColumn, rowId, AccountIdOffset + accountId);
            accountsWire.SetValue(AccountColumns.PersonId, rowId, PersonIdOffset + personId);
            accountsWire.SetValue(AccountColumns.AccountBalance, rowId, balance);
        }
Ejemplo n.º 4
0
        private void AddCurrencyPair(IWritableReactiveTable currencyPairsWire, string ccyPair)
        {
            var row = currencyPairsWire.AddRow();

            currencyPairsWire.SetValue(BrokerTableDefinition.BrokerClientColumns.ClientIpColumn, row, IPAddress.Loopback.ToString());
            currencyPairsWire.SetValue(BrokerTableDefinition.BrokerClientColumns.ClientCcyPairColumn, row, ccyPair);
            currencyPairsWire.SetValue(BrokerTableDefinition.BrokerClientColumns.ClientSide.Selected, row, false);
        }
Ejemplo n.º 5
0
        private static int AddRow(IWritableReactiveTable table, int id, string stringVal, decimal decimalVal)
        {
            var row1 = table.AddRow();

            table.SetValue(TestTableColumns.IdColumn, row1, id);
            table.SetValue(TestTableColumns.StringColumn, row1, stringVal);
            table.SetValue(TestTableColumns.DecimalColumn, row1, decimalVal);
            return(row1);
        }
Ejemplo n.º 6
0
        private void UpdateRates(Dictionary <string, int> ccyPairsToRowIds, IWritableReactiveTable fxRates, bool full = true)
        {
            for (var i = 0; i < _currencyList.Length; i++)
            {
                for (var j = i + 1; j < _currencyList.Length; j++)
                {
                    var ccy1 = _currencyList[i];
                    var ccy2 = _currencyList[j];

                    var ccyPair = ccy1 + ccy2;
                    var rowId   = ccyPairsToRowIds[ccyPair];
                    if (full)
                    {
                        fxRates.SetValue(FxTableDefinitions.FxRates.CcyPairId, rowId, ccyPair);
                    }
                    fxRates.SetValue(FxTableDefinitions.FxRates.Bid, rowId, GetRandomBidAsk());
                    fxRates.SetValue(FxTableDefinitions.FxRates.Ask, rowId, GetRandomBidAsk());
                    fxRates.SetValue(FxTableDefinitions.FxRates.Open, rowId, GetRandomBidAsk());
                    fxRates.SetValue(FxTableDefinitions.FxRates.Close, rowId, GetRandomBidAsk());
                    fxRates.SetValue(FxTableDefinitions.FxRates.YearRangeStart, rowId, GetRandomBidAsk());
                    fxRates.SetValue(FxTableDefinitions.FxRates.YearRangeEnd, rowId, GetRandomBidAsk());
                    fxRates.SetValue(FxTableDefinitions.FxRates.Change, rowId, GetRandomBidAsk());
                    fxRates.SetValue(FxTableDefinitions.FxRates.Time, rowId, DateTime.UtcNow);
//                    var ticksElapsed = DateTime.Now.Ticks - _start.Ticks;
//                    fxRates.SetValue(FxTableDefinitions.FxRates.Ticks, rowId, ticksElapsed);
                }
            }
        }
 public void SetValues(IWritableReactiveTable targetTable)
 {
     while (_updates.Count > 0)
     {
         var update = _updates.Dequeue();
         targetTable.SetValue(update.ColumnId, update.RowIndex, update.Value);
     }
 }
 public void SetValues(IWritableReactiveTable targetTable)
 {
     foreach (var update in _updatesByRow.Values)
     {
         targetTable.SetValue(update.ColumnId, update.RowIndex, update.Value);
     }
     Clear();
 }
Ejemplo n.º 9
0
        /// <summary>
        /// All Broker feeds must be started in same thread so that AddRow is called on same thread.
        /// </summary>
        public void Start()
        {
            _rowIndeces = new int[_ccyPairs.Length * _maturities.Length];
            var count = 0;

            foreach (var ccyPair in _ccyPairs)
            {
                for (var i = 0; i < _maturities.Length; i++)
                {
                    var rowIndex = _table.AddRow();
                    _rowIndeces[count++] = rowIndex;
                    _table.SetValue(BrokerTableDefinition.BrokerColumns.MaturityColumn, rowIndex, _maturities[i]);
                    _table.SetValue(BrokerTableDefinition.BrokerColumns.CcyPairColumn, rowIndex, ccyPair);
                    _table.SetValue(BrokerTableDefinition.BrokerColumns.BrokerNameColumn, rowIndex, Name);
                }
            }
            Task.Run(() => FeedBrokerData());
        }
        private static void UpdateRandomPerson(IWritableReactiveTable people, int maxId, Random random)
        {
            var id       = random.Next(1, maxId);
            var rowIndex = id - 1;

            //            var currentValue = People.GetValue<string>(PersonColumns.NameColumn, rowIndex);
            people.SetValue(PersonColumns.NameColumn, rowIndex, new string('*', random.Next(0, BatchSize)));
            //            People.SetValue(PersonColumns.NameColumn, rowIndex, "Modified at " + DateTime.Now);
        }
        private static void UpdateRandomAccount(IWritableReactiveTable accounts, int maxId, Random random)
        {
            var     id             = random.Next(1, maxId);
            var     rowIndex       = id - 1;
            var     currentBalance = random.Next(0, 100000); // accounts.GetValue<decimal>(AccountColumns.AccountBalance, rowIndex);
            decimal offset         = id % 2 == 0 ? 3242 : -7658;

            accounts.SetValue(AccountColumns.AccountBalance, rowIndex, currentBalance + offset);
        }
Ejemplo n.º 12
0
 public static void SetAndTestValueNotPresent <T>(IWritableReactiveTable setTable,
                                                  IReactiveTable getTable,
                                                  int setRowId,
                                                  int getRowId,
                                                  T value,
                                                  string columnId)
 {
     setTable.SetValue(columnId, setRowId, value);
     Assert.AreEqual(default(T), getTable.GetValue <T>(columnId, getRowId));
 }
        public PersonAccountsViewModel(IReactiveTable personAccounts, IWritableReactiveTable accounts)
        {
            _personAccounts = personAccounts;

            PersonAccounts = new IndexedObservableCollection <PersonAccountViewModel, int>(h => h.RowIndex);
            _subscription  = _personAccounts.ReplayAndSubscribe(OnNext);

            Change = new DelegateCommand(
                () => accounts.SetValue(AccountColumns.AccountBalance, CurrentRowIndex, (decimal)DateTime.Now.Millisecond));

            _personAccounts.ChangeNotifier.RegisterPropertyNotifiedConsumer(this, CurrentRowIndex);
        }
        public void SetValue <T>(int rowIndex, int columnIndex, T value)
        {
            if (_writableTable == null)
            {
                return;
            }

            IReactiveColumn column;
            var             row = GetColAndRowFromGridCoordinates <T>(rowIndex, columnIndex, out column);

            _writableTable.SetValue(column.ColumnId, row, value);
        }
Ejemplo n.º 15
0
 public void OnNext(TableUpdate update)
 {
     _threadMarshaller.Dispatch(
         () =>
     {
         if (update.Action == TableUpdateAction.Add)
         {
             var newRowIndex = _targetTable.AddRow();
             Debug.Assert(update.RowIndex == newRowIndex);
         }
         else if (update.Action == TableUpdateAction.Delete)
         {
             _targetTable.DeleteRow(update.RowIndex);
         }
         else if (update.Action == TableUpdateAction.Update)
         {
             // BUG: When this line is called the original update.Column may not contain the same state as when the outside method is called.
             _targetTable.SetValue(update.Column.ColumnId, update.RowIndex, update.Column, update.RowIndex);
         }
     });
 }
Ejemplo n.º 16
0
        private void SynchroniseChanges(object state)
        {
            // Make copies to control exactly when we lock
            List <TableUpdate> updates;

            lock (_shared)
            {
                if (_updates.Count == 0)
                {
                    return;
                }

                updates = _updates.DequeueAllToList();
            }

            _threadMarshaller.Dispatch(
                () =>
            {
                foreach (var update in updates.Where(TableUpdate.IsRowUpdate))
                {
                    if (update.Action == TableUpdateAction.Add)
                    {
                        _targetTable.AddRow();
                    }
                    else if (update.Action == TableUpdateAction.Delete)
                    {
                        _targetTable.DeleteRow(update.RowIndex);
                    }
                }

                // BUG: When this line is called the original update.Column may not contain the same state as when the outside method is called.
                foreach (var update in updates.Where(TableUpdate.IsColumnUpdate))
                {
                    _targetTable.SetValue(update.Column.ColumnId, update.RowIndex, update.Column, update.RowIndex);
                }
            });
        }
Ejemplo n.º 17
0
 public static void SetAndTestValue <T>(IWritableReactiveTable table, int rowId, T value, string columnId)
 {
     table.SetValue(columnId, rowId, value);
     Assert.AreEqual(value, table.GetValue <T>(columnId, rowId));
 }
Ejemplo n.º 18
0
 public static void SetAndTestValue <T>(IWritableReactiveTable setTable, IReactiveTable getTable, int setRowId, int getRowId, T value, string columnId)
 {
     setTable.SetValue(columnId, setRowId, value);
     TestValue(getTable, getRowId, value, columnId);
 }