internal static OneofAccessor ForRegularOneof( OneofDescriptor descriptor, PropertyInfo caseProperty, MethodInfo clearMethod) => new OneofAccessor( descriptor, ReflectionUtil.CreateFuncIMessageInt32(caseProperty.GetGetMethod()), ReflectionUtil.CreateActionIMessage(clearMethod));
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))); }
private OneofAccessor(OneofDescriptor descriptor, Func <IMessage, int> caseDelegate, Action <IMessage> clearDelegate) { Descriptor = descriptor; this.caseDelegate = caseDelegate; this.clearDelegate = clearDelegate; }