public void Add(Instrument instrument, BarType barType, long barSize) { BarFactoryItem item; switch (barType) { case BarType.Time: item = new TimeBarFactoryItem(instrument, barSize); break; case BarType.Tick: item = new TickBarFactoryItem(instrument, barSize); break; case BarType.Volume: item = new VolumeBarFactoryItem(instrument, barSize); break; default: throw new ArgumentException(string.Format("Unknown bar type - {0}", barType)); } this.Add(item); }