public Version GetVersion(string param, bool allowNull, Version defaultValue) { string value = this.Context.Request.Params[param]; if (allowNull && String.IsNullOrEmpty(value)) { return(defaultValue); } Version rv; if (!Version.TryParse(value, out rv)) { throw new Exception(String.Format(YZStringHelper.ServerSideResourceStringProcess(Resources.YZStrings.Aspx_Request_Params_Invalid_Version), param, value)); } return(rv); }
public Guid GetGuid(string param, bool allowNull) { string value = this.Context.Request.Params[param]; if (allowNull && String.IsNullOrEmpty(value)) { return(Guid.Empty); } Guid rv; if (!Guid.TryParse(value, out rv)) { throw new Exception(String.Format(YZStringHelper.ServerSideResourceStringProcess(Resources.YZStrings.Aspx_Request_Params_Invalid_Guid), param, value)); } return(rv); }
public T GetEnum <T>(string param, bool allowNull, T defaultValue) where T : struct { string value = this.Context.Request.Params[param]; T rv; if (!Enum.TryParse <T>(value, true, out rv)) { if (allowNull) { return(defaultValue); } throw new Exception(String.Format(YZStringHelper.ServerSideResourceStringProcess(Resources.YZStrings.Aspx_Request_Params_Invalid_Type), param, value, typeof(T).Name)); } else { return(rv); } }