protected sealed override MethodInfo GetEventMethod(EventMethodSemantics whichMethod) { NativeFormatMethodSemanticsAttributes localMethodSemantics; switch (whichMethod) { case EventMethodSemantics.Add: localMethodSemantics = NativeFormatMethodSemanticsAttributes.AddOn; break; case EventMethodSemantics.Fire: localMethodSemantics = NativeFormatMethodSemanticsAttributes.Fire; break; case EventMethodSemantics.Remove: localMethodSemantics = NativeFormatMethodSemanticsAttributes.RemoveOn; break; default: return(null); } foreach (MethodSemanticsHandle methodSemanticsHandle in _event.MethodSemantics) { MethodSemantics methodSemantics = methodSemanticsHandle.GetMethodSemantics(_reader); if (methodSemantics.Attributes == localMethodSemantics) { return(RuntimeNamedMethodInfo <NativeFormatMethodCommon> .GetRuntimeNamedMethodInfo(new NativeFormatMethodCommon(methodSemantics.Method, _definingTypeInfo, ContextTypeInfo), ReflectedTypeInfo)); } } return(null); }
protected sealed override MethodInfo GetEventMethod(EventMethodSemantics whichMethod) { NativeFormatMethodSemanticsAttributes localMethodSemantics; switch (whichMethod) { case EventMethodSemantics.Add: localMethodSemantics = NativeFormatMethodSemanticsAttributes.AddOn; break; case EventMethodSemantics.Fire: localMethodSemantics = NativeFormatMethodSemanticsAttributes.Fire; break; case EventMethodSemantics.Remove: localMethodSemantics = NativeFormatMethodSemanticsAttributes.RemoveOn; break; default: return null; } foreach (MethodSemanticsHandle methodSemanticsHandle in _event.MethodSemantics) { MethodSemantics methodSemantics = methodSemanticsHandle.GetMethodSemantics(_reader); if (methodSemantics.Attributes == localMethodSemantics) { return RuntimeNamedMethodInfo<NativeFormatMethodCommon>.GetRuntimeNamedMethodInfo(new NativeFormatMethodCommon(methodSemantics.Method, _definingTypeInfo, ContextTypeInfo), ReflectedTypeInfo); } } return null; }
protected sealed override MethodInfo GetEventMethod(EventMethodSemantics whichMethod) { EventAccessors eventAccessors = _event.GetAccessors(); MethodDefinitionHandle methodHandle; switch (whichMethod) { case EventMethodSemantics.Add: methodHandle = eventAccessors.Adder; break; case EventMethodSemantics.Remove: methodHandle = eventAccessors.Remover; break; case EventMethodSemantics.Fire: methodHandle = eventAccessors.Raiser; break; default: return(null); } /* * This logic is part of the corresponding PropertyInfo code.. should it be here? * bool inherited = !_reflectedType.Equals(ContextTypeInfo); * if (inherited) * { * MethodAttributes flags = _reader.GetMethodDefinition(methodHandle).Attributes; * if ((flags & MethodAttributes.MemberAccessMask) == MethodAttributes.Private) * return null; * } */ return(RuntimeNamedMethodInfo <EcmaFormatMethodCommon> .GetRuntimeNamedMethodInfo(new EcmaFormatMethodCommon(methodHandle, _definingTypeInfo, ContextTypeInfo), ReflectedTypeInfo)); }
/// <summary> /// Override to return the Method that corresponds to the specified semantic. /// Return null if no method is to be found. /// </summary> protected abstract MethodInfo GetEventMethod(EventMethodSemantics whichMethod);