示例#1
0
        /// <summary>
        /// Encodes an unsuccessful status of an operation.
        /// </summary>
        /// <param name="response">The response message, with the success property set to false, and the exception set to the error property.</param>
        /// <param name="error">The inner exception that was raised.</param>
        /// <returns>The response message serialized to a Json string.</returns>
        private static string EncodeFailure(MessageWithSuccessStatus response, Exception error = null)
        {
            response.Success = false;
            if (error == null || !(error is ServiceException))
            {
                error = new ServiceException(ServiceException.InternalError);
            }

            response.Error = ((ServiceException)error).ToDictionary();
            return(response.SerializeToJson());
        }
示例#2
0
 /// <summary>
 /// Encodes a successful status of an operation.
 /// </summary>
 /// <param name="response">The response message, with the success property set to true.</param>
 /// <returns>The response message serialized to a Json string.</returns>
 private static string EncodeSuccess(MessageWithSuccessStatus response)
 {
     response.Success = true;
     return response.SerializeToJson();
 }
示例#3
0
 /// <summary>
 /// Encodes a successful status of an operation.
 /// </summary>
 /// <param name="response">The response message, with the success property set to true.</param>
 /// <returns>The response message serialized to a Json string.</returns>
 private static string EncodeSuccess(MessageWithSuccessStatus response)
 {
     response.Success = true;
     return(response.SerializeToJson());
 }
示例#4
0
        /// <summary>
        /// Encodes an unsuccessful status of an operation.
        /// </summary>
        /// <param name="response">The response message, with the success property set to false, and the exception set to the error property.</param>
        /// <param name="error">The inner exception that was raised.</param>
        /// <returns>The response message serialized to a Json string.</returns>   
        private static string EncodeFailure(MessageWithSuccessStatus response, Exception error = null)
        {
            response.Success = false;
            if (error == null || !(error is ServiceException))
            {
                error = new ServiceException(ServiceException.InternalError);
            }

            response.Error = ((ServiceException)error).ToDictionary();
            return response.SerializeToJson();
        }