/// <summary>
 /// Initializes new instance of <see cref="DocListResponseRow{TDocument}"/> class.
 /// </summary>
 /// <param name="id">ID of the row.</param>
 /// <param name="key">Key of the row.</param>
 /// <param name="value"><see cref="DocListResponseRowValue"/> of the row, which holds revision.</param>
 /// <param name="document">Document.</param>
 /// <param name="error">Error information (if any).</param>
 ///// <exception cref="NoException"></exception>
 public DocListResponseRow(string id, string key, DocListResponseRowValue value, TDocument document, ServerResponseError error)
 {
     Id       = id;
     Key      = key;
     Value    = value;
     Document = document;
     Error    = error;
 }
示例#2
0
        internal ServerResponse(ServerResponseDTO serverResponseDTO)
        {
            if (serverResponseDTO == null)
            {
                throw new ArgumentNullException(nameof(serverResponseDTO));
            }

            OK     = serverResponseDTO.OK;
            Error  = ServerResponseError.FromString(serverResponseDTO.Error, serverResponseDTO.Reason);
            Reason = serverResponseDTO.Reason;
        }
        /// <summary>
        /// Initializes new instance of <see cref="SaveDocResponse"/> class.
        /// </summary>
        /// <param name="docResponseDTO">DTO with vaues for initialization.</param>
        /// <exception cref="ArgumentNullException">Required parameter is null or empty.</exception>
        public SaveDocResponse(CouchDBDatabase.SaveDocResponseDTO docResponseDTO)
        {
            if (docResponseDTO == null)
            {
                throw new ArgumentNullException(nameof(docResponseDTO));
            }

            Id       = docResponseDTO.Id;
            Revision = docResponseDTO.Rev;

            Error = ServerResponseError.FromString(docResponseDTO.Error, docResponseDTO.Reason);
        }
        /// <summary>
        /// Create <see cref="DocListResponseRow{String}"/> by <see cref="JObject"/>.
        /// </summary>
        /// <param name="json"></param>
        /// <returns></returns>
        ///// <exception cref="NoException"></exception>
        internal static DocListResponseRow <string> FromJsonToString(JObject json)
        {
            var id    = SerializationHelper.GetStringOrDefault(json, "id");
            var key   = SerializationHelper.GetStringOrDefault(json, "key");
            var value = SerializationHelper.GetObjectOrDefault(json, "value");
            var doc   = SerializationHelper.GetObjectOrDefault(json, "doc")?.ToString();
            var error = SerializationHelper.GetStringOrDefault(json, "error");

            return(new DocListResponseRow <string>(id, key, DocListResponseRowValue.FromJson(value), doc, ServerResponseError.FromString(error)));
        }