コード例 #1
0
        private async void TickerComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (!contextChanging)
            {
                var newTicker = TickerComboBox.SelectedValue as string;
                var context   = new InstrumentContext()
                {
                    Name = newTicker,
                    Id   = new Dictionary <string, string>()
                    {
                        { "default", newTicker },
                        { "ticker", newTicker }
                    }
                };

                try
                {
                    await connection.BroadcastAsync(context);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
コード例 #2
0
        private void GenerateInstruments()
        {
            var db = new InstrumentContext();

            db.Instruments.RemoveRange(db.Instruments.ToArray());
            db.Currencies.RemoveRange(db.Currencies.ToArray());
            db.SaveChanges();

            var instruments = new[]
            {
                new Instrument
                {
                    Name     = "ERIC B",
                    Currency = new Currency {
                        Id = "SEK"
                    }
                },
                new Instrument
                {
                    Name     = "ERIC B",
                    Currency = new Currency {
                        Id = "USD"
                    }
                },
                new Instrument
                {
                    Name     = "ABCD",
                    Currency = new Currency {
                        Id = "NOK"
                    }
                },
                new Instrument
                {
                    Name     = "TSLA",
                    Currency = new Currency {
                        Id = "USD"
                    }
                },
            };


            db.Instruments.AddRange(instruments);
            db.SaveChanges();
        }