Exemplo n.º 1
0
		/// <summary>
		/// Returns the comment contents after variable expansion.
		/// </summary>
		/// <param name="store">Variable store</param>
		/// <returns>Array of strings containing the initial comments with all variable references expanded</returns>
		public virtual string []  GetLines ( CommentVariables  store )
		   {
			List<string>	lines		=  new List<string> ( ) ;


			foreach  ( string  line  in  TextLines )
			   {
				MatchCollection		matches		=  Regex. Matches ( line, VariableRegexPattern, VariableRegexOptions ) ;
				
				if  ( matches. Count  ==  0 )
				   {
					lines. Add ( line ) ;
					continue ;
				    }

				StringBuilder	newline		=  new StringBuilder ( ) ;
				int		next_index	=  0 ;

				foreach ( Match  match  in  matches )
				   {
					if  ( match. Index  >  0 )
						newline. Append ( line. Substring ( next_index, match. Index - next_index ) ) ;

					next_index	=  match. Index + match. Length ;

					string		vname		=  match. Groups [ "var" ]. Value ;
					string		options		=  match. Groups [ "options" ]. Value ;
					string		value		=  store. Expand ( vname, options ) ;

					newline. Append ( value ) ;
				    }

				if  ( next_index  <  line. Length )
					newline. Append	( line. Substring ( next_index ) ) ;

				lines. Add ( newline. ToString ( ) ) ;
			    }

			return ( lines. ToArray ( ) ) ;
		    }