فهرست منبع

2006-11-22 Igor Zelmanovich <[email protected]>

	* Parameter.cs: fixed Evaluate, ToString methods.
	* QueryStringParameter.cs: fixed Evaluate method.
	* SessionParameter.cs: fixed Evaluate method.


svn path=/trunk/mcs/; revision=68335
Igor Zelmanovich 19 سال پیش
والد
کامیت
a26fb314f5

+ 6 - 0
mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog

@@ -1,3 +1,9 @@
+2006-11-22 Igor Zelmanovich <[email protected]>
+
+	* Parameter.cs: fixed Evaluate, ToString methods.
+	* QueryStringParameter.cs: fixed Evaluate method.
+	* SessionParameter.cs: fixed Evaluate method.
+
 2006-11-21 Igor Zelmanovich <[email protected]>
 
 	* ImageMap.cs: fixed rendering.

+ 10 - 4
mcs/class/System.Web/System.Web.UI.WebControls/Parameter.cs

@@ -121,11 +121,10 @@ namespace System.Web.UI.WebControls {
 			get { return this.IsTrackingViewState; }
 		}
 		
+		// MSDN: The ToString method returns the Name property of the Parameter object. If the Parameter object has no name, ToString returns String.Empty.
 		public override string ToString ()
 		{
-			object o = GetValue (HttpContext.Current, null);
-			if (o != null) return o.ToString();
-			return "";
+			return Name;
 		}
 		
 		[WebCategoryAttribute ("Parameter")]
@@ -237,9 +236,16 @@ namespace System.Web.UI.WebControls {
 			get { return isTrackingViewState; }
 		}
 
+		// MSDN: The default implementation of the Evaluate method is to return 
+		// a null reference (Nothing in Visual Basic) in all cases. 
+		// Classes that derive from the Parameter class override the Evaluate method 
+		// to return an updated parameter value. For example, the ControlParameter object 
+		// returns the value of the control that it is bound to, while 
+		// the QueryStringParameter object retrieves the current name/value pair from 
+		// the HttpRequest object.
 		protected virtual object Evaluate (HttpContext context, Control control)
 		{
-			return this.DefaultValue;
+			return null;
 		}
 		
 		internal object GetValue (HttpContext context, Control control)

+ 2 - 1
mcs/class/System.Web/System.Web.UI.WebControls/QueryStringParameter.cs

@@ -66,7 +66,7 @@ namespace System.Web.UI.WebControls {
 		
 		protected override object Evaluate (HttpContext ctx, Control control)
 		{
-			if (control == null || ctx.Request == null)
+			if (ctx == null || ctx.Request == null)
 				return null;
 			
 			return ctx.Request.QueryString [QueryStringField];
@@ -92,3 +92,4 @@ namespace System.Web.UI.WebControls {
 }
 #endif
 
+

+ 2 - 1
mcs/class/System.Web/System.Web.UI.WebControls/SessionParameter.cs

@@ -65,7 +65,7 @@ namespace System.Web.UI.WebControls {
 		
 		protected override object Evaluate (HttpContext ctx, Control control)
 		{
-			if (control == null || ctx.Session == null)
+			if (ctx == null || ctx.Session == null)
 				return null;
 			
 			return ctx.Session [SessionField];
@@ -92,3 +92,4 @@ namespace System.Web.UI.WebControls {
 }
 #endif
 
+

+ 6 - 0
mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog

@@ -1,3 +1,9 @@
+2006-11-22  Igor Zelmanovich   <[email protected]>
+
+	* ParameterTest.cs: removed NotWorking attributes.
+	* QueryStringParameterTest.cs: removed NotWorking attributes.
+	* SessionParameterTest.cs: removed NotWorking attributes.
+
 2006-11-21  Igor Zelmanovich   <[email protected]>
 
 	* ImageMapTest.cs: removed NotWorking attributes.

+ 2 - 6
mcs/class/System.Web/Test/System.Web.UI.WebControls/ParameterTest.cs

@@ -203,7 +203,6 @@ namespace MonoTests.System.Web.UI.WebControls
 		//Public methods
 
 		[Test]
-		[Category("NotWorking")]
 		public void Parameter_ToString ()
 		{
 			ParameterPoker param = new ParameterPoker ("ID",TypeCode.String ,"1001");
@@ -229,7 +228,6 @@ namespace MonoTests.System.Web.UI.WebControls
 
 		[Test]
 		[Category ("NunitWeb")]
-		[Category("NotWorking")]
 		public void Parameter_Evaluate ()
 		{
 			string html = new WebTest (PageInvoker.CreateOnLoad (
@@ -249,7 +247,6 @@ namespace MonoTests.System.Web.UI.WebControls
 		}
 
 		[Test]
-		[Category("NotWorking")]
 		public void Parameter_DoSetDirty ()
 		{
 			ParameterPoker param = new ParameterPoker ("ID", TypeCode.String, "1001");
@@ -257,8 +254,7 @@ namespace MonoTests.System.Web.UI.WebControls
 			Assert.AreEqual (null, state, "BeforeSetDirtyMethod");
 			param.DoSetDirty ();
 			state = param.SaveState ();
-			Assert.AreEqual(6, ((ArrayList)state).Count , "AfterSetDirtyMethod1");
-			Assert.AreEqual ("ID", ((ArrayList) state)[1], "AfterSetDirtyMethod2");
+			Assert.IsTrue (null != state, "AfterSetDirtyMethod1");
 		}
 
 		[Test]
@@ -280,4 +276,4 @@ namespace MonoTests.System.Web.UI.WebControls
 		}
 	}
 }
-#endif 
+#endif 

+ 4 - 3
mcs/class/System.Web/Test/System.Web.UI.WebControls/QueryStringParameterTest.cs

@@ -133,7 +133,6 @@ namespace MonoTests.System.Web.UI.WebControls
 		}
 
 		[Test]
-		[Category("NotWorking")]
 		public void QueryStringParameter_Evaluate()
 		{
 			QueryStringParameterPoker queryParam = new QueryStringParameterPoker("Employee", TypeCode.Int32, "id");
@@ -146,7 +145,9 @@ namespace MonoTests.System.Web.UI.WebControls
 			HttpContext context = new HttpContext(request, response);
 			value = (string)queryParam.DoEvaluate(context, tb);
 			Assert.AreEqual("332", value, "EvaluateQueryString1");
-			request = new HttpRequest(String.Empty, "http://www.mono-project.com", "id=500");
+			value = (string) queryParam.DoEvaluate (context, null);
+			Assert.AreEqual ("332", value, "EvaluateQueryString1");
+			request = new HttpRequest (String.Empty, "http://www.mono-project.com", "id=500");
 			context = new HttpContext(request, response);
 			value = (string)queryParam.DoEvaluate(context, tb);
 			Assert.AreEqual("500", value, "EvaluateQueryString2");
@@ -156,4 +157,4 @@ namespace MonoTests.System.Web.UI.WebControls
 	}
 }
 
-#endif
+#endif

+ 1 - 2
mcs/class/System.Web/Test/System.Web.UI.WebControls/SessionParameterTest.cs

@@ -135,7 +135,6 @@ namespace MonoTests.System.Web.UI.WebControls
 
 		[Test]
 		[Category("NunitWeb")]
-		[Category("NotWorking")]		
 		public void SessionParameter_Evaluate()
 		{
 			SessionParameterPoker sessionParam = new SessionParameterPoker("employee",TypeCode.String ,"id") ;
@@ -171,4 +170,4 @@ namespace MonoTests.System.Web.UI.WebControls
 
 	}
 }
-#endif
+#endif