Example #1
0
        protected object Deserialize(IRequestContext ctx, Type type)
        {
            R.Helpers.JsonHelper s = new R.Helpers.JsonHelper();
            var item = s.DeserializeObject(ctx.BodyString, type);

            return(item);
        }
Example #2
0
        public async void Respond()
        {
            var ctx = this.HttpContext as HttpContext;

            if (ResponseType == ResponseType.JSON)
            {
                var helper = new R.Helpers.JsonHelper();
                await ctx.Response.WriteAsync(helper.SerializeObject(ctx.Response));
            }
        }
        public async Task Respond(R.Config.IRequestContext request)
        {
            var context = request.HttpContext as HttpContext;

            if (request.ResponseType == ResponseType.JSON)
            {
                context.Response.ContentType = "application/json";
            }
            var json = new R.Helpers.JsonHelper();

            if (request.Response is string)
            {
                await context.Response.WriteAsync((string)request.Response);
            }
            else
            {
                var settings = InitSerialization();
                var s        = JsonConvert.SerializeObject(request.Response, settings);
                await context.Response.WriteAsync(s);
            }
            request.Status = RequestStatus.ResponseSend;
        }