[Quantproject-developers] QuantProject/b4_Business/a2_Strategies/Eligibles EligibleTickers.cs, NON
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2008-01-19 17:40:36
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Eligibles In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv13445/b4_Business/a2_Strategies/Eligibles Added Files: EligibleTickers.cs Log Message: Strongly typed collection of tickers --- NEW FILE: EligibleTickers.cs --- /* QuantProject - Quantitative Finance Library EligibleTickers.cs Copyright (C) 2007 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Data; namespace QuantProject.Business.Strategies.Eligibles { /// <summary> /// Strongly typed collection of tickers /// </summary> public class EligibleTickers : System.Collections.CollectionBase { /// <summary> /// /// </summary> /// <param name="dtTickers">DataTable in the form returned by /// a ticker selector</param> public EligibleTickers( DataTable dtTickers ) { this.addTickers( dtTickers ); } #region addTickers private void checkParameter( DataRow dataRow ) { if ( !( dataRow[ 0 ] is string ) ) throw new Exception( "The datatable of eligible tickers is " + "expected to have a single element in each " + "DataRow and that element should be a string" ); } private void addTicker_actually( string ticker ) { this.List.Add( ticker ); } private void addTicker( DataRow dataRow ) { this.checkParameter( dataRow ); this.addTicker_actually( (string)dataRow[ 0 ] ); } private void addTickers( DataTable dtTickers ) { foreach ( DataRow dataRow in dtTickers.Rows ) this.addTicker( dataRow ); } #endregion addTickers public string this[ int index ] { get { return( (string) this.List[ index ] ); } set { // if ( !(value is string) ) // throw new Exception( "You are trying to add " + // "a ticker that is not a string !!" ); this.List[ index ] = value; } } } } |