internal bool AddReminder(BarFactoryItem item, DateTime dateTime, ClockType type) { bool created = false; SortedList <long, List <BarFactoryItem> > slistByBarSize; if (!this.reminderTable.TryGetValue(dateTime, out slistByBarSize)) { slistByBarSize = new SortedList <long, List <BarFactoryItem> >(); this.reminderTable.Add(dateTime, slistByBarSize); created = true; } List <BarFactoryItem> list; if (!slistByBarSize.TryGetValue(item.barSize, out list)) { list = new List <BarFactoryItem>(); slistByBarSize.Add(item.barSize, list); } list.Add(item); if (created) { var clock = type == ClockType.Exchange ? this.framework.ExchangeClock : this.framework.Clock; return(clock.AddReminder(OnReminder, dateTime)); } return(true); }
public void Remove(BarFactoryItem item) { var list = ItemLists[item.Instrument.Id]; if (list == null) { return; } var found = list.Find(x => x.barType == item.barType && x.barSize == item.barSize && x.barInput == item.barInput); if (found != null) { list.Remove(found); } else { Console.WriteLine($"{DateTime.Now} BarFactory::Remove Item '{item}' is already removed"); } }
// The most important one of all 'Add's public void Add(BarFactoryItem item) { if (item.factory != null) { throw new InvalidOperationException("BarFactoryItem is already added to another BarFactory instance."); } item.factory = this; int id = item.Instrument.Id; var items = ItemLists[id] = ItemLists[id] ?? new List <BarFactoryItem>(); if ( items.Exists( match => item.barType == match.barType && item.barSize == match.barSize && item.barInput == match.barInput && item.providerId == match.providerId)) { Console.WriteLine($"{DateTime.Now} BarFactory::Add Item '{item}' is already added"); } else { items.Add(item); } }
internal bool AddReminder(BarFactoryItem item, DateTime dateTime, ClockType type) { bool created = false; SortedList<long, List<BarFactoryItem>> slistByBarSize; if (!this.reminderTable.TryGetValue(dateTime, out slistByBarSize)) { slistByBarSize = new SortedList<long, List<BarFactoryItem>>(); this.reminderTable.Add(dateTime, slistByBarSize); created = true; } List<BarFactoryItem> list; if (!slistByBarSize.TryGetValue(item.barSize, out list)) { list = new List<BarFactoryItem>(); slistByBarSize.Add(item.barSize, list); } list.Add(item); if (created) { var clock = type == ClockType.Exchange ? this.framework.ExchangeClock : this.framework.Clock; return clock.AddReminder(OnReminder, dateTime); } return true; }
public void Remove(BarFactoryItem item) { var list = ItemLists[item.Instrument.Id]; if (list == null) return; var found = list.Find(x => x.barType == item.barType && x.barSize == item.barSize && x.barInput == item.barInput); if (found != null) list.Remove(found); else Console.WriteLine($"{DateTime.Now} BarFactory::Remove Item '{item}' is already removed"); }
// The most important one of all 'Add's public void Add(BarFactoryItem item) { if (item.factory != null) throw new InvalidOperationException("BarFactoryItem is already added to another BarFactory instance."); item.factory = this; int id = item.Instrument.Id; var items = ItemLists[id] = ItemLists[id] ?? new List<BarFactoryItem>(); if ( items.Exists( match => item.barType == match.barType && item.barSize == match.barSize && item.barInput == match.barInput && item.providerId == match.providerId)) Console.WriteLine($"{DateTime.Now} BarFactory::Add Item '{item}' is already added"); else items.Add(item); }