ParseVar() public method

public ParseVar ( string line ) : string
line string
return string
Esempio n. 1
0
        /// <summary>
        /// </summary>
        public string ParseVar(string line)
        {
            foreach (string s in vars.Keys)
            {
                line = line.Replace(s, (string)vars[s]);
            }

            if (other != null)
            {
                return(other.ParseVar(line));
            }

            return(line);
        }
Esempio n. 2
0
        /// <summary>
        /// </summary>
        public static string ReadLine(StreamReader sr, VarCollection vars)
        {
            string line = "";

            while (true)
            {
                do                 // get a good line - not a comment or empty string
                {
                    if (sr.Peek() != -1)
                    {
                        line = sr.ReadLine().Trim();
                    }
                    else
                    {
                        return(null);
                    }
                }while (line.Length == 0 || line[0] == '#');

                if (line[0] == '$')                 // cache variable, get another line
                {
                    int    idx = line.IndexOf(Separator);
                    string var = line.Substring(0, idx);
                    string val = line.Substring(idx + 1);
                    vars[var] = val;
                }
                else                 // got a line
                {
                    break;
                }
            }

            if (line.IndexOf("$") > 0)             // replace any variables the line might have
            {
                line = vars.ParseVar(line);
            }

            return(line);
        }
Esempio n. 3
0
		public static string ReadLine(StreamReader sr,VarCollection vars)
		{
			string line = "";

			while(true)
			{
				do //get a good line - not a comment or empty string
				{
					if(sr.Peek()!=-1)
						line = sr.ReadLine().Trim();
					else
						return null;
				}while(line.Length==0 || line[0]=='#');

				if(line[0]=='$') //cache variable, get another line
				{
					int idx = line.IndexOf(Separator);
					string var = line.Substring(0,idx);
					string val = line.Substring(idx+1);
					vars[var]=val;
				}
				else //got a line
					break;
			}

			if(line.IndexOf("$")>0) //replace any variables the line might have
				line = vars.ParseVar(line);
			
			return line;
		}