public static MemberInfo ExtractFrom(MethodInfo method, MemberTypes memberType) // settert es esemenyt kifejezesekbol nem fejthetunk ki: https://docs.microsoft.com/en-us/dotnet/csharp/misc/cs0832 { Instruction?call = method.GetInstructions().SingleOrDefault(instruction => instruction.OpCode == OpCodes.Callvirt); if (call != null) { method = (MethodInfo)call.Operand; switch (memberType) { case MemberTypes.Property: PropertyInfo?property = method.DeclaringType.GetProperties().SingleOrDefault(prop => prop.SetMethod == method || prop.GetMethod == method); if (property != null) { return(property); } break; case MemberTypes.Event: EventInfo?evt = method.DeclaringType.GetEvents().SingleOrDefault(evt => evt.AddMethod == method || evt.RemoveMethod == method); if (evt != null) { return(evt); } break; case MemberTypes.Method: return(method); } } throw new NotSupportedException(); }
private static bool InternalIsDefined(EventInfo element, Type attributeType, bool inherit) { Debug.Assert(element != null); // walk up the hierarchy chain if (element.IsDefined(attributeType, inherit)) { return(true); } if (inherit) { AttributeUsageAttribute usage = InternalGetAttributeUsage(attributeType); if (!usage.Inherited) { return(false); } EventInfo?baseEvent = GetParentDefinition(element); while (baseEvent != null) { if (baseEvent.IsDefined(attributeType, false)) { return(true); } baseEvent = GetParentDefinition(baseEvent); } } return(false); }
public static bool AddEventHandler(string typeName, string eventName, EventHandler eventHandler) { string fullEventName = $"{typeName}.{eventName}"; try { Type?type = Type.GetType($"{typeName}, {ServiceRemotingConstants.AssemblyName}", throwOnError: false); if (type == null) { Log.Warning("Could not get type {typeName}.", typeName); return(false); } EventInfo?eventInfo = type.GetEvent(eventName, BindingFlags.Static | BindingFlags.Public); if (eventInfo == null) { Log.Warning("Could not get event {eventName}.", fullEventName); return(false); } // use null target because event is static eventInfo.AddEventHandler(target: null, eventHandler); Log.Debug("Subscribed to event {eventName}.", fullEventName); return(true); } catch (Exception ex) { Log.Error(ex, "Error adding event handler to {eventName}.", fullEventName); return(false); } }
private static Attribute[] InternalGetCustomAttributes(EventInfo element, Type type, bool inherit) { Debug.Assert(element != null); Debug.Assert(type != null); Debug.Assert(type.IsSubclassOf(typeof(Attribute)) || type == typeof(Attribute)); // walk up the hierarchy chain Attribute[] attributes = (Attribute[])element.GetCustomAttributes(type, inherit); if (inherit) { // create the hashtable that keeps track of inherited types Dictionary <Type, AttributeUsageAttribute> types = new Dictionary <Type, AttributeUsageAttribute>(11); // create an array list to collect all the requested attibutes List <Attribute> attributeList = new List <Attribute>(); CopyToArrayList(attributeList, attributes, types); EventInfo?baseEvent = GetParentDefinition(element); while (baseEvent != null) { attributes = GetCustomAttributes(baseEvent, type, false); AddAttributesToList(attributeList, attributes, types); baseEvent = GetParentDefinition(baseEvent); } Attribute[] array = CreateAttributeArrayHelper(type, attributeList.Count); attributeList.CopyTo(array, 0); return(array); } else { return(attributes); } }
public sealed override bool ImplicitlyOverrides(EventInfo?baseMember, EventInfo?derivedMember) { MethodInfo?baseAccessor = GetAccessorMethod(baseMember !); MethodInfo?derivedAccessor = GetAccessorMethod(derivedMember !); return(MemberPolicies <MethodInfo> .Default.ImplicitlyOverrides(baseAccessor, derivedAccessor)); }
public static void Matches(RoutedEventValues expectedValues) { string expectedFieldName = expectedValues.Name + "Event"; FieldInfo?reFieldInfo = expectedValues.OwnerType.GetField(expectedFieldName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); Assert.IsNotNull(reFieldInfo, $"Missing static routed event field `{expectedFieldName}`."); // Check routed event instance. RoutedEvent?routedEvent = reFieldInfo !.GetValue(null) as RoutedEvent; Assert.IsNotNull(routedEvent); Assert.AreEqual(expectedValues.OwnerType, routedEvent !.OwnerType); Assert.AreEqual(expectedValues.Name, routedEvent.Name); Assert.AreEqual(expectedValues.HandlerType, routedEvent.HandlerType); Assert.AreEqual(expectedValues.RoutingStrategy, routedEvent.RoutingStrategy); if (expectedValues.IsAttached) { // Check generated add/remove methods. _AssertMethod($"Add{expectedValues.Name}Handler"); _AssertMethod($"Remove{expectedValues.Name}Handler"); void _AssertMethod(string name) { MethodInfo?methodInfo = expectedValues.OwnerType.GetMethod(name, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); // Exists? Assert.IsNotNull(methodInfo, $"Missing method `{name}`."); // Visibility? Assert.IsTrue(methodInfo !.Attributes.HasFlag(expectedValues.Visibility)); // Parameters? ParameterInfo[] parameters = methodInfo.GetParameters(); Assert.AreEqual(2, parameters.Length); Type targetType = expectedValues.AttachmentNarrowingType ?? typeof(DependencyObject); Assert.AreEqual(targetType, parameters[0].ParameterType); Assert.AreEqual(expectedValues.HandlerType, parameters[1].ParameterType); } } else { // Check generated CLR event. EventInfo?clrEventEventInfo = expectedValues.OwnerType.GetEvent(expectedValues.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); // Exists? Assert.IsNotNull(clrEventEventInfo, $"Missing CLR event `{expectedValues.Name}`."); // Visibility? Assert.IsTrue(clrEventEventInfo !.AddMethod !.Attributes.HasFlag(expectedValues.Visibility)); // Type? Assert.AreEqual(expectedValues.HandlerType, clrEventEventInfo !.EventHandlerType); } }
public ReflectEventDescriptor( [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentClass, EventInfo eventInfo) : base(eventInfo.Name, Array.Empty <Attribute>()) { Debug.Assert(eventInfo.ReflectedType !.IsAssignableFrom(componentClass), "eventInfo.ReflectedType is used below, but only componentClass is annotated with DynamicallyAccessedMembers. Ensure ReflectedType is in componentClass's hierarchy."); _componentClass = componentClass ?? throw new ArgumentException(SR.Format(SR.InvalidNullArgument, nameof(componentClass))); _realEvent = eventInfo; }
void IEventsVisitor.Visit(EndOfTimelineEvent evt) { var eventInfo = new EventInfo(evt, currentTimeOffsets); SetOrigin(eventInfo); if (currentIsLastEventsSet) { endOfTimelineEventInfo = eventInfo; } }
public InternalEventLinker(EventInfo? @event, IViewModel dataContext, string targetName, DependencyObject?host) { _isDirty = @event == null; _host = host; _event = @event; _dataContext = dataContext; _targetName = targetName; Initialize(); }
public override EventInfo?ProjectEvent(EventInfo?value) { if (value == null) { return(null); } Debug.Assert(NeedsProjection(value)); return(new CustomEventInfo(value, ReflectionContext)); }
public static IEnumerable <CustomAttributeData> GetMatchingCustomAttributes(this MemberInfo element, Type optionalAttributeTypeFilter, bool inherit, bool skipTypeValidation = false) { { Type?type = element as Type; if (type != null) { return(TypeCustomAttributeSearcher.Default.GetMatchingCustomAttributes(type, optionalAttributeTypeFilter, inherit, skipTypeValidation: skipTypeValidation)); } } { ConstructorInfo?constructorInfo = element as ConstructorInfo; if (constructorInfo != null) { return(ConstructorCustomAttributeSearcher.Default.GetMatchingCustomAttributes(constructorInfo, optionalAttributeTypeFilter, inherit: false, skipTypeValidation: skipTypeValidation)); } } { MethodInfo?methodInfo = element as MethodInfo; if (methodInfo != null) { return(MethodCustomAttributeSearcher.Default.GetMatchingCustomAttributes(methodInfo, optionalAttributeTypeFilter, inherit, skipTypeValidation: skipTypeValidation)); } } { FieldInfo?fieldInfo = element as FieldInfo; if (fieldInfo != null) { return(FieldCustomAttributeSearcher.Default.GetMatchingCustomAttributes(fieldInfo, optionalAttributeTypeFilter, inherit: false, skipTypeValidation: skipTypeValidation)); } } { PropertyInfo?propertyInfo = element as PropertyInfo; if (propertyInfo != null) { return(PropertyCustomAttributeSearcher.Default.GetMatchingCustomAttributes(propertyInfo, optionalAttributeTypeFilter, inherit, skipTypeValidation: skipTypeValidation)); } } { EventInfo?eventInfo = element as EventInfo; if (eventInfo != null) { return(EventCustomAttributeSearcher.Default.GetMatchingCustomAttributes(eventInfo, optionalAttributeTypeFilter, inherit, skipTypeValidation: skipTypeValidation)); } } if (element == null) { throw new ArgumentNullException(); } throw new NotSupportedException(); // Shouldn't get here. }
public InternalEventLinker(IEnumerable <CommandMember>?member, EventInfo? @event, object dataContext, [NotNull] string targetName, DependencyObject?host) { _isDirty = (member == null) | (@event == null); _host = host; _event = @event; _dataContext = dataContext; _targetName = targetName; FindMember(member); Initialize(); }
public static EventInfo?GetEvent(this Type type, string name, BindingFlags bindingAttr) { EventInfo?found = null; foreach (var eventInfo in type.GetTypeInfo().DeclaredEvents) { if (!string.Equals(eventInfo.Name, name, (bindingAttr & BindingFlags.IgnoreCase) == BindingFlags.Default ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase)) { continue; } if (eventInfo.AddMethod.IsPublic) { if ((bindingAttr & BindingFlags.Public) == BindingFlags.Default) { continue; } } else { if ((bindingAttr & BindingFlags.NonPublic) == BindingFlags.Default) { continue; } } if (eventInfo.AddMethod.IsStatic) { if ((bindingAttr & BindingFlags.Static) == BindingFlags.Default) { continue; } } else { if ((bindingAttr & BindingFlags.Static) == BindingFlags.Default) { continue; } } if (found != null) { throw new AmbiguousMatchException(); } found = eventInfo; } return(found); }
/// <exception cref="ArgumentException">If the named event cannot be found on the given object.</exception> public NativeEventListener(object nativeObject, string nativeEventName) { EventInfo?nativeEvent = nativeObject.GetType().GetTypeInfo().GetEvent(nativeEventName); Type? handlerType = nativeEvent?.EventHandlerType; MethodInfo?invokeMethod = handlerType?.GetMethod("Invoke"); if (nativeEvent == null || handlerType == null || invokeMethod == null) { throw new ArgumentException($"Event {nativeObject.GetType().Name}.{nativeEventName} could not be found"); } ParameterInfo[] parameterInfo = invokeMethod.GetParameters(); Type[] parameterTypes = parameterInfo.Select(param => param.ParameterType).ToArray(); if (!EventProxyStructCache.TryGetValue(parameterTypes, out Type eventProxyStructType)) { if (_moduleBuilder == null) { AssemblyName assemblyName = new("DynamicTypes"); AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run); _moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyName.Name); } long classNumber = Interlocked.Increment(ref _classNameCounter); TypeBuilder typeBuilder = _moduleBuilder.DefineType("EventProxyStruct" + classNumber, TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.SequentialLayout | TypeAttributes.AnsiClass | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, typeof(ValueType)); FieldBuilder actionFieldBuilder = typeBuilder.DefineField(ActionFieldName, typeof(Action), FieldAttributes.Public); MethodBuilder eventHandlerBuilder = typeBuilder.DefineMethod(EventHandlerMethodName, MethodAttributes.Public, invokeMethod.ReturnType, parameterTypes); ILGenerator il = eventHandlerBuilder.GetILGenerator(); il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Ldfld, actionFieldBuilder); il.Emit(OpCodes.Callvirt, typeof(Action).GetMethod(nameof(Action.Invoke)) !); il.Emit(OpCodes.Ret); eventProxyStructType = typeBuilder.CreateType(); EventProxyStructCache[parameterTypes] = eventProxyStructType; } object eventProxyStruct = Activator.CreateInstance(eventProxyStructType); eventProxyStructType.GetField(ActionFieldName).SetValue(eventProxyStruct, (Action)(() => { OnEvent?.Invoke(this, EventArgs.Empty); })); MethodInfo eventReceiverMethod = eventProxyStructType.GetMethod(EventHandlerMethodName) !; Delegate eventHandlerDelegate = Delegate.CreateDelegate(handlerType, eventProxyStruct, eventReceiverMethod); nativeEvent.AddEventHandler(nativeObject, eventHandlerDelegate); }
protected override void OnAttachedTo(Xamarin.Forms.View visualElement) { base.OnAttachedTo(visualElement); var events = AssociatedObject?.GetType().GetRuntimeEvents().ToArray(); if (events.Any()) { _eventInfo = events.FirstOrDefault(e => e.Name == EventName); if (_eventInfo == null) { throw new ArgumentException(String.Format("EventToCommand: Can't find any event named '{0}' on attached type", EventName)); } MethodInfo methodInfo = typeof(EventToCommandBehavior).GetTypeInfo().GetDeclaredMethod("OnFired"); _handler = methodInfo.CreateDelegate(_eventInfo.EventHandlerType, this); _eventInfo.AddEventHandler(AssociatedObject, _handler); //AddEventHandler(_eventInfo, AssociatedObject, OnFired); } }
internal EventOnTypeBuilderInst(TypeBuilderInstantiation instantiation, EventInfo evt) { this.instantiation = instantiation; this.event_info = evt; }
public static Chart CreateChartFromXml(Stream inStream) { using var reader = XmlReader.Create(inStream); var chart = MusecloneChartFactory.Instance.CreateNew(); var timingInfo = new Dictionary <int, TimingInfo>(); var eventInfos = new List <EventInfo>(); EventInfo?curEvent = null; reader.MoveToContent(); #region Read Timing Information and Event Creation while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.EndElement: if (reader.Name == "event") { //Logger.Log($"End event block: {curEvent!.StartTimeMillis}, {curEvent!.EndTimeMillis}, {curEvent!.Type}, {curEvent!.Kind}"); eventInfos.Add(curEvent !); curEvent = null; } break; case XmlNodeType.Element: { if (reader.Name == "tempo") { int time = 0, deltaTime = 0, value = 500_000; long bpm = 120_00; while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case "time": { //string type = reader["__type"]; reader.Read(); // <time ...> time = reader.ReadContentAsInt(); } break; case "delta_time": { //string type = reader["__type"]; reader.Read(); // <delta_time ...> deltaTime = reader.ReadContentAsInt(); } break; case "val": { //string type = reader["__type"]; reader.Read(); // <delta_time ...> value = reader.ReadContentAsInt(); } break; case "bpm": { //string type = reader["__type"]; reader.Read(); // <delta_time ...> bpm = reader.ReadContentAsLong(); } break; } } else if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "tempo") { //Logger.Log($"End tempo block: {time}, {deltaTime}, {value}, {bpm}"); if (!timingInfo.TryGetValue(time, out var info)) { timingInfo[time] = info = new TimingInfo(); } info.MusecaWhen = time; info.BeatsPerMinute = bpm / 100.0; break; } } } else if (reader.Name == "sig_info") { int time = 0, deltaTime = 0, num = 4, denomi = 4; while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case "time": { //string type = reader["__type"]; reader.Read(); // <time ...> time = reader.ReadContentAsInt(); } break; case "delta_time": { //string type = reader["__type"]; reader.Read(); // <delta_time ...> deltaTime = reader.ReadContentAsInt(); } break; case "num": { //string type = reader["__type"]; reader.Read(); // <delta_time ...> num = reader.ReadContentAsInt(); } break; case "denomi": { //string type = reader["__type"]; reader.Read(); // <delta_time ...> denomi = reader.ReadContentAsInt(); } break; } } else if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "sig_info") { //Logger.Log($"End sig_info block: {time}, {deltaTime}, {num}, {denomi}"); if (!timingInfo.TryGetValue(time, out var info)) { timingInfo[time] = info = new TimingInfo(); } info.Numerator = num; info.Denominator = denomi; break; } } } switch (reader.Name) { case "event": curEvent = new EventInfo(); break; case "stime_ms": { reader.Read(); curEvent !.StartTimeMillis = reader.ReadContentAsLong(); } break; case "etime_ms": { reader.Read(); curEvent !.EndTimeMillis = reader.ReadContentAsLong(); } break; case "type": { reader.Read(); curEvent !.Type = reader.ReadContentAsInt(); } break; case "kind": { reader.Read(); curEvent !.Kind = reader.ReadContentAsInt(); } break; } } break; } } #endregion #region Construct :theori Timing Data foreach (var info in from pair in timingInfo orderby pair.Key select pair.Value) { tick_t position = chart.CalcTickFromTime(info.MusecaWhen / 1000.0); var cp = chart.ControlPoints.GetOrCreate(position, true); if (info.BeatsPerMinute > 0) { cp.BeatsPerMinute = info.BeatsPerMinute; } if (info.Numerator != 0 && info.Denominator != 0 && (cp.BeatCount != info.Numerator || cp.BeatKind != info.Denominator)) { cp = chart.ControlPoints.GetOrCreate(MathL.Ceil((double)position), true); cp.BeatCount = info.Numerator; cp.BeatKind = info.Denominator; } } #endregion #region Determine timing info from beat events if (false && timingInfo.Count == 0) { var barEvents = from e in eventInfos where e.Kind == 11 || e.Kind == 12 select e; // bpm related long lastBeatDurationMillis = 0, lastBeatStartMillis = 0, lastBpmStartMillis = 0; int bpmTotalBeats = 0; long runningBeatDurationTotal = 0; int numBeatsCounted = 0; // sig related int n = 4; int measure = 0, totalMeasures = 0, beatCount = 0, totalBeatsInMeasure = 0; long sigMeasureStartMillis = 0, sigCurrentMeasureStartMillis = 0, sigOffsetMillis = 0; tick_t offset = 0; var bpmChanges = new Dictionary <int, (long Millis, double BeatsPerMinute)>(); var timeSigChanges = new Dictionary <int, (int Numerator, int Denominator)>(); foreach (var e in barEvents) { long millis = e.StartTimeMillis; if (totalBeatsInMeasure > 0) { lastBpmStartMillis = lastBeatStartMillis; long beatDuration = millis - lastBeatStartMillis; if (lastBeatDurationMillis != 0) { // TODO(local): if this is within like a millisecond then maybe it's fine if (Math.Abs(beatDuration - lastBeatDurationMillis) > 10) { bpmChanges[bpmTotalBeats] = (lastBpmStartMillis, 60_000.0 / (runningBeatDurationTotal / (double)numBeatsCounted)); lastBpmStartMillis = lastBeatStartMillis; numBeatsCounted = 0; runningBeatDurationTotal = 0; } } lastBeatDurationMillis = beatDuration; } bpmTotalBeats++; numBeatsCounted++; runningBeatDurationTotal += millis - lastBeatStartMillis; lastBeatStartMillis = millis; if (e.Kind == 11) // measure marker { totalMeasures++; if (totalBeatsInMeasure == 0) // first one in the chart { sigOffsetMillis = millis; sigMeasureStartMillis = millis; beatCount++; totalBeatsInMeasure++; } else // check that the previous beat count matches `n` { if (beatCount != n) { timeSigChanges[totalMeasures - 1] = (beatCount, 4); totalBeatsInMeasure = 0; measure = 0; } // continue as normal totalBeatsInMeasure++; measure++; beatCount = 1; sigCurrentMeasureStartMillis = millis; } } else // beat marker { beatCount++; totalBeatsInMeasure++; } } bpmChanges[bpmTotalBeats] = (lastBeatStartMillis, 60_000.0 / (runningBeatDurationTotal / (double)numBeatsCounted)); chart.Offset = sigOffsetMillis / 1_000.0; foreach (var(measureIndex, (num, denom)) in timeSigChanges) { tick_t position = measureIndex; var cp = chart.ControlPoints.GetOrCreate(position, true); cp.BeatCount = num; cp.BeatKind = denom; } foreach (var(beatIndex, (timeMillis, bpm)) in bpmChanges) { int beatsLeft = beatIndex; tick_t? where = null; foreach (var cp in chart.ControlPoints) { if (!cp.HasNext) { where = cp.Position + (double)beatsLeft / cp.BeatCount; break; } else { int numBeatsInCp = (int)(cp.BeatCount * (double)(cp.Next.Position - cp.Position)); if (beatsLeft > numBeatsInCp) { beatsLeft -= numBeatsInCp; } else { where = cp.Position + (double)beatsLeft / cp.BeatCount; break; } } } if (where.HasValue) { var cp = chart.ControlPoints.GetOrCreate(where.Value, true); cp.BeatsPerMinute = bpm; } //else Logger.Log($"Bpm change at beat {beatIndex} (timeMillis) could not be created for bpm {bpm}"); } } #endregion var noteInfos = from e in eventInfos where e.Kind != 11 && e.Kind != 12 && e.Kind != 14 && e.Kind != 15 select e; foreach (var entity in noteInfos) { tick_t startTicks = chart.CalcTickFromTime(entity.StartTimeMillis / 1000.0); tick_t endTicks = chart.CalcTickFromTime(entity.EndTimeMillis / 1000.0); const int q = 192; startTicks = MathL.Round((double)(startTicks * q)) / q; endTicks = MathL.Round((double)(endTicks * q)) / q; tick_t durTicks = endTicks - startTicks; if (entity.Kind == 1 && entity.Type == 5) { chart[5].Add <ButtonEntity>(startTicks, durTicks); } else { switch (entity.Kind) { // "chip" tap note case 0: chart[entity.Type].Add <ButtonEntity>(startTicks); break; // hold tap note, ignore foot pedal bc handled above case 1: chart[entity.Type - 6].Add <ButtonEntity>(startTicks, durTicks); break; // large spinner case 2: { var e = chart[entity.Type % 6].Add <SpinnerEntity>(startTicks, durTicks); e.Large = true; } break; // large spinner left case 3: { var e = chart[entity.Type % 6].Add <SpinnerEntity>(startTicks, durTicks); e.Direction = LinearDirection.Left; e.Large = true; } break; // large spinner right case 4: { var e = chart[entity.Type % 6].Add <SpinnerEntity>(startTicks, durTicks); e.Direction = LinearDirection.Right; e.Large = true; } break; // small spinner case 5: { var e = chart[entity.Type].Add <SpinnerEntity>(startTicks); } break; // small spinner left case 6: { var e = chart[entity.Type].Add <SpinnerEntity>(startTicks); e.Direction = LinearDirection.Left; } break; // small spinner right case 7: { var e = chart[entity.Type].Add <SpinnerEntity>(startTicks); e.Direction = LinearDirection.Right; } break; } } } return(chart); }
/// <summary> /// This fills the get and set method fields of the event info. It is shared /// by the various constructors. /// </summary> private void FillMethods() { if (_filledMethods) { return; } if (_realEvent != null) { _addMethod = _realEvent.GetAddMethod(); _removeMethod = _realEvent.GetRemoveMethod(); EventInfo?defined = null; if (_addMethod == null || _removeMethod == null) { Type?start = _componentClass.BaseType; while (start != null && start != typeof(object)) { BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; EventInfo test = start.GetEvent(_realEvent.Name, bindingFlags) !; if (test.GetAddMethod() != null) { defined = test; break; } } } if (defined != null) { _addMethod = defined.GetAddMethod(); _removeMethod = defined.GetRemoveMethod(); _type = defined.EventHandlerType; } else { _type = _realEvent.EventHandlerType; } } else { // first, try to get the eventInfo... _realEvent = _componentClass.GetEvent(Name); if (_realEvent != null) { // if we got one, just recurse and return. FillMethods(); return; } Type[] argsType = new Type[] { _type ! }; _addMethod = FindMethod(_componentClass, "AddOn" + Name, argsType, typeof(void)); _removeMethod = FindMethod(_componentClass, "RemoveOn" + Name, argsType, typeof(void)); if (_addMethod == null || _removeMethod == null) { Debug.Fail($"Missing event accessors for {_componentClass.FullName}. {Name}"); throw new ArgumentException(SR.Format(SR.ErrorMissingEventAccessors, Name)); } } _filledMethods = true; }
public abstract EventInfo?ProjectEvent(EventInfo?value);