2 using System.Collections.Generic;
3 using System.Collections.Specialized;
5 using System.Reflection;
9 namespace MonoTests.Common
11 class MyHttpRequestWrapper : HttpRequestBase
13 Dictionary<string, object> propertyValues = new Dictionary<string, object> ();
15 public override string AppRelativeCurrentExecutionFilePath
20 if (!GetProperty<string> ("AppRelativeCurrentExecutionFilePath", out value))
21 return base.AppRelativeCurrentExecutionFilePath;
27 public override string PathInfo
32 if (!GetProperty<string> ("PathInfo", out value))
39 public override NameValueCollection QueryString
43 NameValueCollection value;
44 if (!GetProperty<NameValueCollection> ("QueryString", out value))
45 return base.QueryString;
51 bool GetProperty<T> (string name, out T value)
53 if (String.IsNullOrEmpty (name))
54 throw new ArgumentNullException ("name");
58 if (propertyValues.TryGetValue (name, out v)) {
61 if (typeof (T).IsAssignableFrom (v.GetType ())) {
66 throw new InvalidOperationException ("Invalid value type. Expected '" + typeof (T) + "' and got '" + v.GetType () + "'");
72 public void SetProperty (string name, object value)
74 if (String.IsNullOrEmpty (name))
77 if (propertyValues.ContainsKey (name))
78 propertyValues[name] = value;
80 propertyValues.Add (name, value);