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

pull/288/head
csharptest 13 years ago committed by rogerk
parent 0e152e4386
commit 3cf3315370
  1. 6
      src/ProtocolBuffers/FieldAccess/RepeatedPrimitiveAccessor.cs
  2. 12
      src/ProtocolBuffers/FieldAccess/SinglePrimitiveAccessor.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;

@ -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");

Loading…
Cancel
Save