File: search.aspx.cs

package info (click to toggle)
mono 3.2.8%2Bdfsg-10
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 527,964 kB
  • ctags: 623,327
  • sloc: cs: 3,938,236; xml: 1,891,753; ansic: 418,737; java: 59,920; sh: 15,754; makefile: 11,067; sql: 7,956; perl: 2,279; cpp: 1,380; yacc: 1,203; python: 594; asm: 422; sed: 16; php: 1
file content (46 lines) | stat: -rw-r--r-- 1,921 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.Compilation;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class search : System.Web.UI.Page
{
	protected void Page_Load (object sender, EventArgs e)
	{
		string searchterm = Page.RouteData.Values ["searchterm"] as string;
		label1.Text = searchterm;

		var sb = new StringBuilder ();
		RunTest (sb, "Missing key", "SearchTermd", typeof (Label), "Text");
		RunTest (sb, "Missing property", "SearchTerm", typeof (Label), "NoSuchPropertyHere");
		RunTest (sb, "No converter", "SearchTerm", typeof (Image), "Font");
		RunTest (sb, "Valid conversion to target", "SearchTerm", typeof (Image), "Enabled");
		RunTest (sb, "Invalid conversion to target", "SearchTerm", typeof (HotSpot), "TabIndex");
		RunTest (sb, "Complex type converter", "SearchTerm", typeof (Style), "BackColor");
		RunTest (sb, "Null controlType", "SearchTerm", null, "Text");
		RunTest (sb, "Null propertyName", "SearchTerm", typeof (Label), null);
		RunTest (sb, "Empty propertyName", "SearchTerm", typeof (Label), String.Empty);
		RunTest (sb, "Non-string value", "intValue", typeof (Label), "Text");
		RunTest (sb, "Non-string value", "boolValue", typeof (Label), "Text");
		RunTest (sb, "Non-string value", "doubleValue", typeof (Label), "Text");

		testLog.InnerText = sb.ToString ();
	}

	void RunTest (StringBuilder sb, string title, string key, Type controlType, string propertyName)
	{
		sb.AppendFormat (".: {0} (key: '{1}')\n", title, key);
		try {
			object val = RouteValueExpressionBuilder.GetRouteValue (this, key, controlType, propertyName);
			if (val != null)
				sb.AppendFormat ("\tReturned value of type '{0}': {1}\n", val.GetType (), val.ToString ());
			else
				sb.AppendFormat ("\tReturned null.\n");
		} catch (Exception ex) {
			sb.AppendFormat ("\tException '{0}' caught\n", ex.GetType ());
		}
	}
}