/// <summary> /// Sets up the reader for reading rows from the response data set. /// </summary> private void BeginValueSection() { switch (_reader.TokenType) { case JsonToken.StartObject: // The response only contains a single row (JSON object instead of JSON array). _resultType = WebApiResultType.SingleRow; break; case JsonToken.StartArray: // The response contains multiple rows (JSON array). _resultType = WebApiResultType.MultipleRows; break; default: // The response contains a single value (JSON primitive). _resultType = WebApiResultType.Scalar; break; } // When the BeginValueSection does not get called, _resultType defaults to NoResult. }
/// <summary> /// 构造函数 /// </summary> /// <param name="success"></param> /// <param name="msg"></param> /// <param name="data"></param> public WebApiResult(WebApiResultType resultType = WebApiResultType.NoChanged, string msg = null, object data = null) : base(resultType, msg, data) { }
/// <summary> /// Reads a single scalar result from the response JSON. /// </summary> /// <remarks> /// This method is used when the response only has a single scalar result. After the result is read, /// the state of the IDataReader is set to indicate there are no more rows /// </remarks> /// <returns>true always</returns> private bool ReadSingleScalar() { ReadScalarRow(); _resultType = WebApiResultType.NoResult; return(true); }
/// <summary> /// Reads a single row from the response JSON. /// </summary> /// <remarks> /// This method is used when the response only has a single row result. After the row is read, /// the state of the IDataReader is set to indicate there are no more rows /// </remarks> /// <returns>true always</returns> private bool ReadSingleRow() { ReadObjectRow(); _resultType = WebApiResultType.NoResult; return(true); }