public WebError(string message) { Code = WebErrorCode.BadRequest; Message = ContractHelper.RequiresNotNull(message); HttpStatusCode = HttpStatusCode.BadRequest; UseServiceErrorMessage = false; MessageFields = new ExpandoObject(); }
/// <summary> /// Adds all the entries in a <see cref="IEnumerable{T}"/> to the target <see cref="ICollection{T}"/> /// </summary> /// <typeparam name="T"></typeparam> /// <param name="target"></param> /// <param name="source"></param> public static void AddRange <T>(this ICollection <T> target, IEnumerable <T> source) { ContractHelper.RequiresNotNull(target); foreach (var element in ContractHelper.RequiresNotNull(source)) { target.Add(element); } }
/// <summary> /// /// </summary> /// <param name="code"></param>S /// <param name="message"></param> /// <param name="httpStatusCode"></param> /// <param name="useServiceErrorMessage">If true, then the service error message will be used</param> public WebError(WebErrorCode code, string message, HttpStatusCode httpStatusCode, bool useServiceErrorMessage = false) { Code = code; Message = ContractHelper.RequiresNotNull(message); HttpStatusCode = httpStatusCode; UseServiceErrorMessage = useServiceErrorMessage; MessageFields = new ExpandoObject(); }
/// <summary> /// Create a new web service result that passes along the service errors /// </summary> public WebServiceResult(ServiceError error) { ContractHelper.RequiresNotNull(error); WebErrors = SingletonList.Of(WebError.FromServiceError(error)); }
/// <summary> /// Create a new web service result that passes along the result of a call to a service. /// </summary> /// <param name="result">The result of a service call.</param> public WebServiceResult(ServiceResult <T> payload) { Payload = ContractHelper.RequiresNotNull(payload).Payload; WebErrors = payload.Errors.Select(WebError.FromServiceError).ToList(); }
/// <summary> /// Create a new web service result with an <paramref name="error"/> to return to the caller. /// </summary> /// <param name="error">The error encountered by the web service.</param> public WebServiceResult(WebError error) : this() { WebErrors.Add(ContractHelper.RequiresNotNull(error)); }
/// <summary> /// Create a new web service result with no errors with the specified result /// </summary> public WebServiceResult(T payload) { Payload = ContractHelper.RequiresNotNull(payload); WebErrors = new List <WebError>(); }