//	public _ParamParser()
	//	{			
	//	}
	

		#region function Paramparser_NameValue

		/// <summary>
		/// Parses name-value params.
		/// </summary>
		/// <param name="source">Parse source.</param>
		/// <param name="expressions">Expressions importance order. NOTE: must contain param and value groups.</param>
		public static _Parameter[] Paramparser_NameValue(string source,string[] expressions)
		{
			string tmp = source.Trim();
			ArrayList param = new ArrayList();
			foreach(string exp in expressions){
				Regex r = new Regex(exp,RegexOptions.IgnoreCase);
				Match m = r.Match(tmp);				
				if(m.Success){
					param.Add(new _Parameter(m.Result("${param}").Trim(),m.Result("${value}")));

					// remove matched string part form tmp
					tmp = tmp.Replace(m.ToString(),"").Trim();
				}				
			}

			// There are some unparsed params, add them as UnParsed
			if(tmp.Trim().Length > 0){
				param.Add(new _Parameter("UNPARSED",tmp));
			}

			_Parameter[] retVal = new _Parameter[param.Count];
			param.CopyTo(retVal);

			return retVal;
		}
示例#2
0
        //	public _ParamParser()
        //	{
        //	}


        #region function Paramparser_NameValue

        /// <summary>
        /// Parses name-value params.
        /// </summary>
        /// <param name="source">Parse source.</param>
        /// <param name="expressions">Expressions importance order. NOTE: must contain param and value groups.</param>
        public static _Parameter[] Paramparser_NameValue(string source, string[] expressions)
        {
            string    tmp   = source.Trim();
            ArrayList param = new ArrayList();

            foreach (string exp in expressions)
            {
                Regex r = new Regex(exp, RegexOptions.IgnoreCase);
                Match m = r.Match(tmp);
                if (m.Success)
                {
                    param.Add(new _Parameter(m.Result("${param}").Trim(), m.Result("${value}")));

                    // remove matched string part form tmp
                    tmp = tmp.Replace(m.ToString(), "").Trim();
                }
            }

            // There are some unparsed params, add them as UnParsed
            if (tmp.Trim().Length > 0)
            {
                param.Add(new _Parameter("UNPARSED", tmp));
            }

            _Parameter[] retVal = new _Parameter[param.Count];
            param.CopyTo(retVal);

            return(retVal);
        }