Subversion Repositories DevTools

Rev

Rev 2106 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2104 ghuddy 1
using System;
2
using System.Text;
3
 
4
namespace EA_DocGen
5
{
6
	/// <summary>
7
	/// Summary description for DocSectionTracking.
8
	/// </summary>
9
	public class DocSectionTracking
10
	{
2106 ghuddy 11
      private static int[] DocSection = null;
12
      private static int   iDocSection = 0;
2104 ghuddy 13
 
2106 ghuddy 14
		public static void initialise()
2104 ghuddy 15
		{
16
         DocSection = new int[EA_Constants.MAX_HEADING_LEVEL + 1];
17
         for (int i=0; i<DocSection.Length; i++)
18
         {
19
            DocSection[i] = 0;
20
         }
21
         iDocSection = 0;
22
		}
23
 
24
 
2106 ghuddy 25
      public static void trackDocSection(int recurse_level)
2104 ghuddy 26
      {
27
         if (recurse_level > EA_Constants.MAX_HEADING_LEVEL)
28
         {
29
            throw new System.StackOverflowException(EA_Constants.maxRecursionDepthException );
30
         }
31
 
32
         iDocSection = recurse_level;
33
         DocSection[iDocSection]++;     
34
         for (int i=iDocSection+1; i<DocSection.Length; i++)
35
            DocSection[i] = 0;
36
      }
37
 
2106 ghuddy 38
      public static void appendHeadingNumber(ref StringBuilder sb)
2104 ghuddy 39
      {
40
         for (int i = 1; i<=iDocSection; i++)
41
         {
42
            if (i!=1)
43
               sb.Append(".");
44
            sb.Append(DocSection[i].ToString());
45
         }
46
      }
47
 
2106 ghuddy 48
      public static string formHeadingString(string headingName)
2104 ghuddy 49
      {
50
         StringBuilder sb = new StringBuilder("");
51
         appendHeadingNumber(ref sb);
52
         sb.Append("\t");
2132 ghuddy 53
         if (headingName != null)
54
            sb.Append(headingName);
2104 ghuddy 55
         return sb.ToString();
56
      }
57
	}
58
}