Several hundred StyleCop fixes.
[dotnetoauth.git] / src / DotNetOpenAuth.Test / Hosting / AspNetHost.cs
blob015a00b1e7446e976b511da082dcf3dc978f69fc
1 //-----------------------------------------------------------------------
2 // <copyright file="AspNetHost.cs" company="Andrew Arnott">
3 // Copyright (c) Andrew Arnott. All rights reserved.
4 // </copyright>
5 //-----------------------------------------------------------------------
7 namespace DotNetOpenAuth.Test.Hosting {
8 using System;
9 using System.IO;
10 using System.Net;
11 using System.Threading;
12 using System.Web;
13 using System.Web.Hosting;
14 using DotNetOpenAuth.Messaging;
15 using DotNetOpenAuth.Test.OpenId;
17 /// <summary>
18 /// Hosts a 'portable' version of the OpenIdProvider for testing itself and the
19 /// RelyingParty against it.
20 /// </summary>
21 internal class AspNetHost : MarshalByRefObject {
22 private HttpHost httpHost;
24 public AspNetHost() {
25 httpHost = HttpHost.CreateHost(this);
26 ////if (!UntrustedWebRequestHandler.WhitelistHosts.Contains("localhost"))
27 //// UntrustedWebRequestHandler.WhitelistHosts.Add("localhost");
30 public Uri BaseUri {
31 get { return httpHost.BaseUri; }
34 public static AspNetHost CreateHost(string webDirectory) {
35 AspNetHost host = (AspNetHost)ApplicationHost.
36 CreateApplicationHost(typeof(AspNetHost), "/", webDirectory);
37 return host;
40 public string ProcessRequest(string url) {
41 return httpHost.ProcessRequest(url);
44 public string ProcessRequest(string url, string body) {
45 return httpHost.ProcessRequest(url, body);
48 public void BeginProcessRequest(HttpListenerContext context) {
49 ThreadPool.QueueUserWorkItem(state => { ProcessRequest(context); });
52 public void ProcessRequest(HttpListenerContext context) {
53 try {
54 using (TextWriter tw = new StreamWriter(context.Response.OutputStream)) {
55 HttpRuntime.ProcessRequest(new TestingWorkerRequest(context, tw));
57 } catch (Exception ex) {
58 Logger.Error("Exception in AspNetHost", ex);
59 throw;
63 public void CloseHttp() {
64 httpHost.Dispose();