示例#1
0
		public void Write(IReportWriter writer)
		{
			MetricGroup lastGroup = _heirarchy[_heirarchy.Length - 1];

			List<MetricCounter> items = new List<MetricCounter>(lastGroup);
			items.Sort(new Comparer(_groupings));

			_opened = new MetricCounter[_heirarchy.Length];

			writer.StartGroup(_heirarchy[0]);

			foreach (MetricCounter counter in items)
			{
				if (counter.Excluded == false)
					WriteItem(writer, counter);
			}

			//close open
			for (int ix = _groupings.Length - 1; ix >= 0; ix--)
			{
				if (_opened[ix] != null)
					writer.StopItem(_heirarchy[ix], _opened[ix]);
				_opened[ix] = null;
			}

			writer.StopGroup(_heirarchy[0]);
		}
        private void WriteItem(IReportWriter writer, MetricCounter counter)
        {
            CodeMetric current = counter.Group;
            int        ixDiff  = 0;

            while (ixDiff < _groupings.Length && _opened[ixDiff] != null && _groupings[ixDiff].Equals(current, _opened[ixDiff].Group))
            {
                ixDiff++;
            }

            //close open
            for (int ix = _groupings.Length - 1; ix >= ixDiff; ix--)
            {
                if (_opened[ix] != null)
                {
                    writer.StopItem(_heirarchy[ix], _opened[ix]);
                }
                _opened[ix] = null;
            }

            //open new
            for (int ix = ixDiff; ix < _opened.Length - 1 && _opened[ix] == null; ix++)
            {
                writer.StartItem(_heirarchy[ix], _opened[ix] = _heirarchy[ix][counter.Group]);
            }

            writer.WriteItem(_heirarchy[_heirarchy.Length - 1], counter);
        }