diff options
author | Jan Tattermusch <jtattermusch@users.noreply.github.com> | 2015-07-22 10:36:06 -0700 |
---|---|---|
committer | Jan Tattermusch <jtattermusch@users.noreply.github.com> | 2015-07-22 10:36:06 -0700 |
commit | 7b5c3967991b6534f439cb31b0d247501f4a0ef8 (patch) | |
tree | e161b4bfaa308ca173ee9a8b2ff858c5b76b618b /csharp/src/Google.Protobuf/Reflection/OneofAccessor.cs | |
parent | 2ee4b5665520fe3245eb5e15df8bd35e0c539a07 (diff) | |
parent | 43d64b4f54c8cf9521aded37fc695faba28793ee (diff) | |
download | protobuf-7b5c3967991b6534f439cb31b0d247501f4a0ef8.tar.gz protobuf-7b5c3967991b6534f439cb31b0d247501f4a0ef8.tar.bz2 protobuf-7b5c3967991b6534f439cb31b0d247501f4a0ef8.zip |
Merge pull request #625 from jskeet/reflection-refactor
Reflection refactor
Diffstat (limited to 'csharp/src/Google.Protobuf/Reflection/OneofAccessor.cs')
-rw-r--r-- | csharp/src/Google.Protobuf/Reflection/OneofAccessor.cs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/csharp/src/Google.Protobuf/Reflection/OneofAccessor.cs b/csharp/src/Google.Protobuf/Reflection/OneofAccessor.cs index 7a11d36b..20cbea92 100644 --- a/csharp/src/Google.Protobuf/Reflection/OneofAccessor.cs +++ b/csharp/src/Google.Protobuf/Reflection/OneofAccessor.cs @@ -44,18 +44,16 @@ namespace Google.Protobuf.Reflection private readonly Action<object> clearDelegate; private OneofDescriptor descriptor; - internal OneofAccessor(Type type, string propertyName, OneofDescriptor descriptor) + internal OneofAccessor(PropertyInfo caseProperty, MethodInfo clearMethod, OneofDescriptor descriptor) { - PropertyInfo property = type.GetProperty(propertyName + "Case"); - if (property == null || !property.CanRead) + if (!caseProperty.CanRead) { - throw new ArgumentException("Not all required properties/methods available"); + throw new ArgumentException("Cannot read from property"); } this.descriptor = descriptor; - caseDelegate = ReflectionUtil.CreateFuncObjectT<int>(property.GetGetMethod()); + caseDelegate = ReflectionUtil.CreateFuncObjectT<int>(caseProperty.GetGetMethod()); this.descriptor = descriptor; - MethodInfo clearMethod = type.GetMethod("Clear" + propertyName); clearDelegate = ReflectionUtil.CreateActionObject(clearMethod); } |