示例#1
0
        public void Write(AnalysisResult r, IProcessor<KeyValuePair<string,int>> cutoffPolicy, int topRecords)
        {
            if (r.FileChurn.Any() == false)
                return;

            IEnumerable<KeyValuePair<string, int>> fileChurns = cutoffPolicy.Apply(r.FileChurn).Take(topRecords);

            WriteImpl(fileChurns);
            _out.Flush();
        }
示例#2
0
        public void Write(AnalysisResult r, IProcessor<KeyValuePair<string,int>> cutoffPolicy , int top)
        {
            if (r.FileChurn.Any() == false)
                return;

            int max = r.FileChurn.Max(x => x.Key.Length);
            var i = r.FileChurn.FirstOrDefault().Value.ToString().Length;


            //padding
           
            var total = max + i + 3; //separators | .. | .. |
            string hline = "+".PadRight(total+3, '-')+"+";
            StringBuilder sb = new StringBuilder();
            sb.AppendLine(hline);
            foreach (var kvp in cutoffPolicy.Apply(r.FileChurn).Take(top))
            {
                sb.Append("| ").Append(kvp.Key.PadRight(max)).Append(" | ").Append(kvp.Value.ToString().PadRight(i)).AppendLine(" |");
            }
            sb.AppendLine(hline);
            _out.Write(sb.ToString());
            _out.Flush();
        }