Author: kostat
Date: 2007-01-11 09:15:20 -0500 (Thu, 11 Jan 2007)
New Revision: 70860
Modified:
branches/mainsoft/gh20preview2/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
branches/mainsoft/gh20preview2/mcs/class/System.Web/System.Web.UI.WebControls/ObjectDataSourceView.cs
branches/mainsoft/gh20preview2/mcs/class/System.Web/Test/System.Web.UI.WebControls/ObjectDataSourceViewTest.cs
Log:
merge -r 70858:70859
Modified:
branches/mainsoft/gh20preview2/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
===================================================================
---
branches/mainsoft/gh20preview2/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
2007-01-11 14:13:17 UTC (rev 70859)
+++
branches/mainsoft/gh20preview2/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
2007-01-11 14:15:20 UTC (rev 70860)
@@ -1,3 +1,8 @@
+2007-01-10 Konstantin Triger <[EMAIL PROTECTED]>
+
+ * ObjectDataSourceView.cs: consider parameter names and
+ DataObjectMethodAttribute during method resolution.
+
2007-01-11 Vladimir Krasnov <[EMAIL PROTECTED]>
* SqlDataSourceView.cs: fixed OnUpdating, OnInserting call with
Modified:
branches/mainsoft/gh20preview2/mcs/class/System.Web/System.Web.UI.WebControls/ObjectDataSourceView.cs
===================================================================
---
branches/mainsoft/gh20preview2/mcs/class/System.Web/System.Web.UI.WebControls/ObjectDataSourceView.cs
2007-01-11 14:13:17 UTC (rev 70859)
+++
branches/mainsoft/gh20preview2/mcs/class/System.Web/System.Web.UI.WebControls/ObjectDataSourceView.cs
2007-01-11 14:15:20 UTC (rev 70860)
@@ -585,7 +585,7 @@
if (DataObjectTypeName.Length == 0) {
paramValues = MergeParameterValues
(InsertParameters, values, null, true);
- method = GetObjectMethod (InsertMethod,
paramValues);
+ method = GetObjectMethod (InsertMethod,
paramValues, DataObjectMethodType.Insert);
} else {
method = ResolveDataObjectMethod (InsertMethod,
values, null, out paramValues);
}
@@ -632,7 +632,7 @@
if (DataObjectTypeName.Length == 0) {
paramValues = MergeParameterValues
(DeleteParameters, null, oldDataValues, true);
- method = GetObjectMethod (DeleteMethod,
paramValues);
+ method = GetObjectMethod (DeleteMethod,
paramValues, DataObjectMethodType.Delete);
} else {
method = ResolveDataObjectMethod (DeleteMethod,
oldDataValues, null, out paramValues);
}
@@ -678,7 +678,7 @@
dataValues = values;
}
paramValues = MergeParameterValues
(UpdateParameters, dataValues, oldDataValues, false);
- method = GetObjectMethod (UpdateMethod,
paramValues);
+ method = GetObjectMethod (UpdateMethod,
paramValues, DataObjectMethodType.Update);
}
else
{
@@ -814,7 +814,7 @@
object InvokeSelect (string methodName, IOrderedDictionary
paramValues)
{
- MethodInfo method = GetObjectMethod (methodName,
paramValues);
+ MethodInfo method = GetObjectMethod (methodName,
paramValues, DataObjectMethodType.Select);
ObjectDataSourceStatusEventArgs rargs = InvokeMethod
(method, paramValues);
OnSelected (rargs);
@@ -860,20 +860,69 @@
}
}
- MethodInfo GetObjectMethod (string methodName,
IOrderedDictionary parameters)
+ MethodInfo GetObjectMethod (string methodName,
IOrderedDictionary parameters, DataObjectMethodType methodType)
{
- MemberInfo[] methods = ObjectType.GetMember
(methodName, BindingFlags.Instance |
+ MemberInfo[] methods = ObjectType.GetMember
(methodName, MemberTypes.Method, BindingFlags.Instance |
BindingFlags.Static |
BindingFlags.Public |
BindingFlags.FlattenHierarchy);
if (methods.Length > 1) {
// MSDN: The ObjectDataSource resolves method
overloads by method name and number
// of parameters; the names and types of the
parameters are not considered.
- foreach (MemberInfo mi in methods) {
- MethodInfo me = mi as MethodInfo;
- if (me != null &&
me.GetParameters().Length == parameters.Count)
- return me;
+ // LAMESPEC: the tests show otherwise
+ DataObjectMethodAttribute methodAttribute =
null;
+ MethodInfo methodInfo = null;
+ bool hasConflict = false;
+ foreach (MethodInfo me in methods) { // we look
for methods only
+ ParameterInfo [] pinfos =
me.GetParameters ();
+ if (pinfos.Length == parameters.Count) {
+ object [] attrs =
me.GetCustomAttributes (typeof (DataObjectMethodAttribute), true);
+ DataObjectMethodAttribute
domAttr = (attrs != null && attrs.Length > 0) ? (DataObjectMethodAttribute)
attrs [0] : null;
+ if (domAttr != null &&
domAttr.MethodType != methodType)
+ continue;
+
+ bool paramsMatch = true;
+ foreach (ParameterInfo pinfo in
pinfos) {
+ if
(!parameters.Contains (pinfo.Name)) {
+ paramsMatch =
false;
+ break;
+ }
+ }
+
+ if (!paramsMatch)
+ continue;
+
+ if (domAttr != null) {
+ if (methodAttribute !=
null) {
+ if
(methodAttribute.IsDefault) {
+ if
(domAttr.IsDefault) {
+
methodInfo = null;
+
break; //fail due to a conflict
+ }
+ else
+
continue; //existing matches better
+ }
+ else {
+
methodInfo = null; //we override
+
hasConflict = !domAttr.IsDefault;
+ }
+ }
+ else
+ methodInfo =
null; //we override
+ }
+
+ if (methodInfo == null) {
+ methodAttribute =
domAttr;
+ methodInfo = me;
+ continue;
+ }
+
+ hasConflict = true;
+ }
}
+
+ if (!hasConflict && methodInfo != null)
+ return methodInfo;
}
else if (methods.Length == 1) {
MethodInfo me = methods[0] as MethodInfo;
Modified:
branches/mainsoft/gh20preview2/mcs/class/System.Web/Test/System.Web.UI.WebControls/ObjectDataSourceViewTest.cs
===================================================================
---
branches/mainsoft/gh20preview2/mcs/class/System.Web/Test/System.Web.UI.WebControls/ObjectDataSourceViewTest.cs
2007-01-11 14:13:17 UTC (rev 70859)
+++
branches/mainsoft/gh20preview2/mcs/class/System.Web/Test/System.Web.UI.WebControls/ObjectDataSourceViewTest.cs
2007-01-11 14:15:20 UTC (rev 70860)
@@ -37,6 +37,7 @@
using NUnit.Framework;
using System;
+using Sys = System;
using System.Configuration;
using System.Data.Common;
using System.IO;
@@ -883,6 +884,14 @@
{
return ds;
}
+
+
[Sys.ComponentModel.DataObjectMethod(Sys.ComponentModel.DataObjectMethodType.Select,
false)]
+ public static DataTable Select (int maximumRows, short
startRowIndex) {
+ Assert.Fail ("Should not be called since not default
Select DataObjectMethod");
+ return null;
+ }
+
+
[Sys.ComponentModel.DataObjectMethod(Sys.ComponentModel.DataObjectMethodType.Select,
true)]
public static DataTable Select (int maximumRows, int
startRowIndex)
{
DataSourceObject.maximumRows = maximumRows;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches