Author: jbevain
Date: 2008-01-25 09:38:55 -0500 (Fri, 25 Jan 2008)
New Revision: 93901

Modified:
   trunk/mcs/class/System.Core/System.Linq.Expressions/ChangeLog
   trunk/mcs/class/System.Core/System.Linq.Expressions/Expression.cs
Log:
2008-01-25  Jb Evain  <[EMAIL PROTECTED]>

        * Expression.cs: implement PropertyOrField.



Modified: trunk/mcs/class/System.Core/System.Linq.Expressions/ChangeLog
===================================================================
--- trunk/mcs/class/System.Core/System.Linq.Expressions/ChangeLog       
2008-01-25 14:32:27 UTC (rev 93900)
+++ trunk/mcs/class/System.Core/System.Linq.Expressions/ChangeLog       
2008-01-25 14:38:55 UTC (rev 93901)
@@ -1,3 +1,7 @@
+2008-01-25  Jb Evain  <[EMAIL PROTECTED]>
+
+       * Expression.cs: implement PropertyOrField.
+
 2008-01-24  Jb Evain  <[EMAIL PROTECTED]>
 
        * Expression.cs, MemberExpression.cs, ExpressionPrinter.cs:

Modified: trunk/mcs/class/System.Core/System.Linq.Expressions/Expression.cs
===================================================================
--- trunk/mcs/class/System.Core/System.Linq.Expressions/Expression.cs   
2008-01-25 14:32:27 UTC (rev 93900)
+++ trunk/mcs/class/System.Core/System.Linq.Expressions/Expression.cs   
2008-01-25 14:38:55 UTC (rev 93901)
@@ -1462,10 +1462,22 @@
                        return new MemberExpression (expression, prop, 
prop.PropertyType);
                }
 
-               [MonoTODO]
                public static MemberExpression PropertyOrField (Expression 
expression, string propertyOrFieldName)
                {
-                       throw new NotImplementedException ();
+                       if (expression == null)
+                               throw new ArgumentNullException ("expression");
+                       if (propertyOrFieldName == null)
+                               throw new ArgumentNullException 
("propertyOrFieldName");
+
+                       var prop = expression.Type.GetProperty 
(propertyOrFieldName, AllInstance);
+                       if (prop != null)
+                               return new MemberExpression (expression, prop, 
prop.PropertyType);
+
+                       var field = expression.Type.GetField 
(propertyOrFieldName, AllInstance);
+                       if (field != null)
+                               return new MemberExpression (expression, field, 
field.FieldType);
+
+                       throw new ArgumentException (string.Format ("No field 
or property named {0} on {1}", propertyOrFieldName, expression.Type));
                }
 
                public static UnaryExpression Quote (Expression expression)

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to