コード例 #1
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="sr">File to read</param>
		public VarCollection_Structure(StreamReader sr)
		{
			VarCollection vc = new VarCollection(sr);

			root = new KeyVal("parent", "parent");
			root.SubHash = new Dictionary<string, KeyVal>();
			
			parse_block(vc,root);
		}
コード例 #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="sr">File to read</param>
        public VarCollection_Structure(StreamReader sr)
        {
            VarCollection vc = new VarCollection(sr);

            root         = new KeyVal("parent", "parent");
            root.SubHash = new Dictionary <string, KeyVal>();

            parse_block(vc, root);
        }
コード例 #3
0
		private void parse_block(VarCollection vc,KeyVal parent)
		{
			KeyVal kv;
			KeyVal lastKV=null;
			while (vc.ReadLine(out kv))
			{
				switch (kv.Keyword)
				{
					case "{":
						lastKV.SubHash = new Dictionary<string, KeyVal>();
						parse_block(vc,lastKV);
						break;
					case "}":
						return;
					default:
						parent.SubHash[kv.Keyword]=kv;
						lastKV = kv;
						break;
				}
			}
		}
コード例 #4
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);
        }
コード例 #5
0
        private void parse_block(VarCollection vc, KeyVal parent)
        {
            KeyVal kv;
            KeyVal lastKV = null;

            while (vc.ReadLine(out kv))
            {
                switch (kv.Keyword)
                {
                case "{":
                    lastKV.SubHash = new Dictionary <string, KeyVal>();
                    parse_block(vc, lastKV);
                    break;

                case "}":
                    return;

                default:
                    parent.SubHash[kv.Keyword] = kv;
                    lastKV = kv;
                    break;
                }
            }
        }
コード例 #6
0
 /// <summary>
 /// </summary>
 public VarCollection(VarCollection other)
     :
     this()
 {
     this.other = other;
 }
コード例 #7
0
 /// <summary>
 /// </summary>
 public VarCollection(StreamReader sr)
 {
     this.sr = sr;
     vars    = new Dictionary <string, Variable>();
     other   = null;
 }
コード例 #8
0
 /// <summary>
 /// </summary>
 public VarCollection()
 {
     vars    = new Dictionary <string, Variable>();
     other   = null;
     baseVar = "";
 }
コード例 #9
0
		public VarCollection(VarCollection other)
			: this()
		{
			this.other = other;
		}
コード例 #10
0
		public VarCollection(StreamReader sr)
		{
			this.sr = sr;
			vars = new Dictionary<string, Variable>();
			other = null;
		}
コード例 #11
0
		public VarCollection()
		{
			vars = new Dictionary<string, Variable>();
			other = null;
			baseVar = "";
		}
コード例 #12
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;
		}