public ViewCommand(Session session) : base(session) { Name = CommandName; Params = new Param[1]; var ptype = new PType {Help = "View name type", Method = MethodType.Regexp, Name = "view_name_string"}; Configuration.PTypes.Add(ptype.Name, ptype); var param = new Param {Help = "View name for getting scope of commands.", Name = "viewname", PType = "view_name_string"}; Params[0] = param; Action = new Action {Text = "view ${viewname}"}; }
/// <summary> /// Resolves the param. /// </summary> /// <param name="rawCommand">The raw command.</param> /// <param name="type">The type.</param> /// <returns></returns> public static String ResolveParam(String rawCommand, PType type) { String param = String.Empty; switch (type.Method) { case MethodType.Integer: param = GetParamByPattern(rawCommand, IntegerPattern); param = !type.Numbers.Contains(param) ? String.Empty : Convert.ToInt32(param).ToString(); break; case MethodType.Regexp: // INFO: We need to check this method for errors. if (!String.IsNullOrEmpty(type.Pattern)) { param = GetParamByPattern(rawCommand, type.Pattern); } else { param = GetParamByPattern(rawCommand, StringPattern); } break; break; case MethodType.Select: // INFO: what we need to write there for complete. !!!!!!!!!!!! param = type.Selections.Where(rawCommand.Contains).FirstOrDefault(); break; } return param; }