소스 검색

Fix for GetProperty(string, Type[]) incompatible with Silverlight

csharptest 13 년 전
부모
커밋
3cf3315370
2개의 변경된 파일7개의 추가작업 그리고 11개의 파일을 삭제
  1. 3 3
      src/ProtocolBuffers/FieldAccess/RepeatedPrimitiveAccessor.cs
  2. 4 8
      src/ProtocolBuffers/FieldAccess/SinglePrimitiveAccessor.cs

+ 3 - 3
src/ProtocolBuffers/FieldAccess/RepeatedPrimitiveAccessor.cs

@@ -66,9 +66,9 @@ namespace Google.ProtocolBuffers.FieldAccess
 
         internal RepeatedPrimitiveAccessor(string name)
         {
-            PropertyInfo messageProperty = typeof(TMessage).GetProperty(name + "List", ReflectionUtil.EmptyTypes);
-            PropertyInfo builderProperty = typeof(TBuilder).GetProperty(name + "List", ReflectionUtil.EmptyTypes);
-            PropertyInfo countProperty = typeof(TMessage).GetProperty(name + "Count", ReflectionUtil.EmptyTypes);
+            PropertyInfo messageProperty = typeof(TMessage).GetProperty(name + "List");
+            PropertyInfo builderProperty = typeof(TBuilder).GetProperty(name + "List");
+            PropertyInfo countProperty = typeof(TMessage).GetProperty(name + "Count");
             MethodInfo clearMethod = typeof(TBuilder).GetMethod("Clear" + name, EmptyTypes);
             getElementMethod = typeof(TMessage).GetMethod("Get" + name, new Type[] {typeof(int)});
             clrType = getElementMethod.ReturnType;

+ 4 - 8
src/ProtocolBuffers/FieldAccess/SinglePrimitiveAccessor.cs

@@ -58,14 +58,10 @@ namespace Google.ProtocolBuffers.FieldAccess
 
         internal SinglePrimitiveAccessor(string name)
         {
-            PropertyInfo messageProperty = typeof(TMessage).GetProperty(name, ReflectionUtil.EmptyTypes);
-            PropertyInfo builderProperty = typeof(TBuilder).GetProperty(name, ReflectionUtil.EmptyTypes);
-            if (builderProperty == null)
-            {
-                builderProperty = typeof(TBuilder).GetProperty(name, ReflectionUtil.EmptyTypes);
-            }
-            PropertyInfo hasProperty = typeof(TMessage).GetProperty("Has" + name, ReflectionUtil.EmptyTypes);
-            MethodInfo clearMethod = typeof(TBuilder).GetMethod("Clear" + name, ReflectionUtil.EmptyTypes);
+            PropertyInfo messageProperty = typeof(TMessage).GetProperty(name, null, ReflectionUtil.EmptyTypes);
+            PropertyInfo builderProperty = typeof(TBuilder).GetProperty(name, null, ReflectionUtil.EmptyTypes);
+            PropertyInfo hasProperty = typeof(TMessage).GetProperty("Has" + name);
+            MethodInfo clearMethod = typeof(TBuilder).GetMethod("Clear" + name);
             if (messageProperty == null || builderProperty == null || hasProperty == null || clearMethod == null)
             {
                 throw new ArgumentException("Not all required properties/methods available");