public override decimal GetStat( string theKey ) { var season = theKey.Substring( 0, 4 ); var week = theKey.Substring( 5, 2 ); var playerId = theKey.Substring( 8, 8 ); var stat = new GridStatsOutput { Season = season, Week = week, PlayerId = playerId, Quantity = 0.0M }; #if DEBUG Utility.Announce( string.Format( "GridStatsMaster:Getting Stat {0}", stat.FormatKey() ) ); #endif var key = stat.FormatKey(); if ( TheHt.ContainsKey( key ) ) { stat = (GridStatsOutput) TheHt[ key ]; CacheHits++; } else { // new it up #if DEBUG Utility.Announce( string.Format( "GridStatsMaster:Instantiating Stat {0}", stat.FormatKey() ) ); #endif PutStat( stat ); IsDirty = true; CacheMisses++; } return stat.Quantity; }
private static void WriteStatNode( XmlWriter writer, GridStatsOutput stat ) { writer.WriteStartElement( "stat" ); writer.WriteAttributeString( "season", stat.Season ); writer.WriteAttributeString( "week", stat.Week ); writer.WriteAttributeString( "id", stat.PlayerId ); writer.WriteAttributeString( "qty", stat.Quantity.ToString() ); writer.WriteAttributeString( "opp", stat.Opponent ); writer.WriteEndElement(); }
public void PutStat( GridStatsOutput stat ) { if ( stat.Quantity == 0.0M ) return; IsDirty = true; if ( TheHt.ContainsKey( stat.FormatKey() ) ) { TheHt[ stat.FormatKey() ] = stat; return; } TheHt.Add( stat.FormatKey(), stat ); }