protected static void ApplyComments(StreamWriter sw, TxtFormat format, TxtLine line)
        {
            string tab = format.CommentsFormat != null ? format.CommentsFormat : string.Empty;

            if (line.Comments != null)
            {
                sw.WriteLine("{0}/// <summary>", tab);
                sw.WriteLine("{0}/// {1}", tab, line.Comments);
                sw.WriteLine("{0}/// </summary>", tab);
            }
        }
 protected static void PrintWithTab(StreamWriter sw, TxtFormat format, string s)
 {
     if (format.CommentsFormat != null)
     {
         sw.WriteLine(format.CommentsFormat + s);
     }
     else
     {
         sw.WriteLine(s);
     }
 }
        protected string ApplyFormat(TxtFormat format, TxtLine line)
        {
            List <string> values = new List <string>();

            foreach (string parameter in format.Parameters)
            {
                if (line.Values[HeadersHash[parameter]] == "_")
                {
                    return(null);
                }
                values.Add(line.Values[HeadersHash[parameter]]);
            }

            return(string.Format(format.Format, values.ToArray()));
        }
        public TxtLine[] Read(StreamReader sr)
        {
            //Reading formats!
            List <TxtFormat> formats = new List <TxtFormat>();
            string           header  = GetNext(sr);

            TxtFormat format = null;

            while (header.Trim().StartsWith("#"))
            {
                string[] temps = TxtFormat.SplitSharp(header);


                switch (temps[0].Trim())
                {
                case "+":
                    format.Format += "\n" + temps[1];
                    break;

                case "n":
                case "*":
                    format.Format = temps[1];
                    break;

                case "p":
                    format.Parameters = TxtFormat.Split(temps[1]);
                    break;

                case "=":
                    formats.Add(format);
                    break;

                case "name":
                    format      = new TxtFormat();
                    format.Name = temps[1];
                    break;

                case "c":
                    format.CommentsFormat = temps[1];
                    break;

                case "h":
                    format.Header.Add(temps[1]);
                    break;

                case "f":
                    format.Footer.Add(temps[1]);
                    break;

                case "g_h":
                    Header.Add(temps[1]);
                    break;

                case "g_f":
                    Footer.Add(temps[1]);
                    break;
                }

                header = GetNext(sr);
            }
            Formats = formats.ToArray();

            //Reading headers!
            Headers = Split(header);
            HashHeaders();

            //reading lines!
            List <TxtLine> list     = new List <TxtLine>();
            string         comments = null;

            while (!sr.EndOfStream)
            {
                //Reading line from source file
                string temp = GetNextAndComments(sr);

                if (temp.StartsWith("///"))
                {
                    comments = temp.Substring(3);
                    continue;
                }

                //creating new instance
                list.Add(new TxtLine(SplitTab(temp), comments));
                comments = null;
            }

            return(list.ToArray());
        }