Exemplo n.º 1
0
        internal override void WriteReturns(object[] returnValues, Stream outputStream)
        {
            if (serverMethod.writerType == null)
            {
                return;
            }
            MimeReturnWriter writer = (MimeReturnWriter)MimeFormatter.CreateInstance(serverMethod.writerType,
                                                                                     serverMethod.writerInitializer);

            writer.Write(Response, outputStream, returnValues[0]);
        }
Exemplo n.º 2
0
        public override void ProcessRequest(HttpContext context)
        {
            Context = context;
            Stream    respStream = null;
            Exception error      = null;

            try
            {
                if (method == null)
                {
                    method = (HttpSimpleMethodStubInfo)GetRequestMethod(context);
                }

                if (method.MethodInfo.EnableSession)
                {
                    Session = context.Session;
                }

                MimeParameterReader parameterReader = (MimeParameterReader)method.ParameterReaderType.Create();
                object[]            parameters      = parameterReader.Read(context.Request);

                MimeReturnWriter returnWriter = (MimeReturnWriter)method.ReturnWriterType.Create();
                object           result       = Invoke(method.MethodInfo, parameters);
                respStream = context.Response.OutputStream;
                returnWriter.Write(context.Response, respStream, result);
            }
            catch (Exception ex)
            {
                error = ex;
            }

            if (error != null)
            {
                WriteError(context, error.ToString());
            }

            if (respStream != null)
            {
                respStream.Close();
            }
        }