public virtual string CreateResponse(Customer customer, ResponseKind responseKind)
        {
            if (responseKind == ResponseKind.HTML)
                return new HtmlSerializer().SerializeToHtml(customer);

            return new XmlSerializer().SerializeToXml(customer);
        }
示例#2
0
        public Response <T> SetStatus(ResponseKind status, string errorMessage = null, IEnumerable <ErrorMessage> errors = null)
        {
            ErrorKind    = status;
            ErrorMessage = errorMessage;
            Errors       = errors;

            return(this);
        }
示例#3
0
        public Response <T> SetError(string errorMessage, ResponseKind errorKind, IEnumerable <ErrorMessage> errors = null)
        {
            ErrorMessage = errorMessage;
            ErrorKind    = errorKind;
            Errors       = errors;

            return(this);
        }
 public bool Equals(ResponseKind other)
 {
     if (ReferenceEquals(null, other))
         return false;
     if (ReferenceEquals(this, other))
         return true;
     return Equals(other.kind, kind);
 }
示例#5
0
        private ObjectResult BuildError(object data, ResponseKind statusCode)
        {
            if (statusCode == ResponseKind.InternalServerError)
            {
                Console.Write($"[ERROR] {_path} ({{@data}})", data);
            }

            return(new ObjectResult(data)
            {
                StatusCode = (int)statusCode
            });
        }
示例#6
0
 public void Deconstruct(out ResponseKind kind, out object arg)
 {
     kind = this.kind;
     arg  = this.arg;
 }
示例#7
0
 public Response(ResponseKind kind, object arg)
 {
     this.kind = kind;
     this.arg  = arg;
 }
示例#8
0
            internal static HttpResponseMessage GetResponse(HttpStatusCode statusCode, ResponseKind resKind, LroHeaders headers)
            {
                HttpResponseMessage res = GetResponse(statusCode, resKind);

                //res = AddHeaders(res, headers);

                return(res);
            }
示例#9
0
            internal static HttpResponseMessage GetResponse(HttpStatusCode statusCode, ResponseKind resKind)
            {
                HttpResponseMessage res = new HttpResponseMessage();

                switch (resKind)
                {
                case ResponseKind.Initial:
                    res.Content = new StringContent(InitialResponse);
                    break;

                case ResponseKind.IntrimPolling:
                    res.Content = new StringContent(IntrimPollingResponse_1);
                    break;

                case ResponseKind.PostPolling:
                    res.Content = new StringContent(LH_FinalResource);
                    break;
                }

                return(res);
            }