protected void WriteTick(StockTick tick) { lock (gate) { var output = new System.Text.StringBuilder(); Action <string> traceStrategy; if (tick.Change > 0) { output.Append('↑'); output.Append(' '); traceStrategy = TraceStatus; } else if (tick.Change < 0) { output.Append('↓'); output.Append(' '); traceStrategy = TraceWarning; } else { output.Append('-'); output.Append(' '); traceStrategy = TraceLine; } output.Append(tick); traceStrategy(output.ToString()); } }
public StockAlert(IEnumerable <StockTick> prefix, StockTick tick) { Contract.Requires(prefix != null); this.tick = tick; this.prefixAsString = prefix.Aggregate( new StringBuilder(), (builder, t) => builder.Append(t.Value).Append(','), builder => (builder.Length == 0) ? string.Empty : builder.ToString(0, builder.Length - 1)); }