Пример #1
0
        public StringResult Page(XrcUrl url, object parameters = null, IContext callerContext = null)
        {
            try
            {
                var parentRequest = callerContext == null ? null : callerContext.Request;
                var parentResponse = callerContext == null ? null : callerContext.Response;

                using (var stream = new MemoryStream())
                {
                    var request = new XrcRequest(url, parentRequest: parentRequest);
                    var response = new XrcResponse(stream, parentResponse: parentResponse);
                    var context = new Context(request, response);

                    context.CallerContext = callerContext;
                    AddParameters(context, parameters);

                    ProcessRequest(context);

                    context.CheckResponse();

                    response.Flush();

                    stream.Seek(0, SeekOrigin.Begin);

                    using (StreamReader reader = new StreamReader(stream, response.ContentEncoding))
                    {
                        return new StringResult(reader.ReadToEnd(), response.ContentEncoding, response.ContentType);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new PageException(url.AppRelaviteUrl, ex);
            }
        }
Пример #2
0
 public Context(XrcRequest request, XrcResponse response)
 {
     _request = request;
     _response = response;
 }
Пример #3
0
 public Context(HttpContextBase httpContext)
 {
     _request = new XrcRequest(httpContext.Request);
     _response = new XrcResponse(httpContext.Response);
 }