/// <summary> /// 根据指定键获取不允许为空的字符串 /// </summary> /// <param name="requestKey"></param> /// <param name="fieldTitle"></param> /// <returns></returns> protected string TryGetString(string requestKey, string fieldTitle) { string strdata = HttpContext.Current.Request[requestKey]; InputChecker.CheckResult checkResult = InputChecker.CheckData(strdata, InputCheckType.NotNUll); return(TryGetString(requestKey, fieldTitle, InputCheckType.NotNUll)); }
/// <summary> /// 获取符合InputCheckTypes规则的字符串 /// </summary> /// <param name="requestKey">key</param> /// <param name="fieldTitle">the field's name</param> /// <param name="InputCheckTypes">check type</param> /// <returns></returns> protected string TryGetString(string requestKey, string fieldTitle, params InputCheckType[] InputCheckTypes) { string strdata = HttpContext.Current.Request[requestKey]; InputChecker.CheckResult checkResult = InputChecker.CheckData(strdata, InputCheckTypes); if (checkResult.status == InputChecker.CheckResult.Status.Failed) { throw new Exception("内容[" + fieldTitle + "]" + checkResult.Message); } else { return(strdata); } }