Ejemplo n.º 1
0
 internal static OneofAccessor ForRegularOneof(
     OneofDescriptor descriptor,
     PropertyInfo caseProperty,
     MethodInfo clearMethod) =>
 new OneofAccessor(
     descriptor,
     ReflectionUtil.CreateFuncIMessageInt32(caseProperty.GetGetMethod()),
     ReflectionUtil.CreateActionIMessage(clearMethod));
Ejemplo n.º 2
0
 internal static OneofAccessor ForSyntheticOneof(OneofDescriptor descriptor)
 {
     // Note: descriptor.Fields will be null when this method is called, because we haven't
     // cross-linked yet. But by the time the delegates are called by user code, all will be
     // well. (That's why we capture the descriptor itself rather than a field.)
     return(new OneofAccessor(descriptor,
                              message => descriptor.Fields[0].Accessor.HasValue(message) ? descriptor.Fields[0].FieldNumber : 0,
                              message => descriptor.Fields[0].Accessor.Clear(message)));
 }
Ejemplo n.º 3
0
 private OneofAccessor(OneofDescriptor descriptor, Func <IMessage, int> caseDelegate, Action <IMessage> clearDelegate)
 {
     Descriptor         = descriptor;
     this.caseDelegate  = caseDelegate;
     this.clearDelegate = clearDelegate;
 }