Skip to content
This repository has been archived by the owner on Jan 16, 2022. It is now read-only.

Commit

Permalink
Misc.
Browse files Browse the repository at this point in the history
  • Loading branch information
Abrynos committed Sep 28, 2021
1 parent 6dbb506 commit e51608a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
12 changes: 0 additions & 12 deletions Implement.Net/Extensions/ReflectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,6 @@

namespace Implement.Net.Extensions {
internal static class ReflectionExtensions {
internal static bool CanAdd(this EventInfo @event) {
MethodInfo? addMethod = @event.GetAddMethod(true);

return addMethod != null;
}

internal static bool CanRemove(this EventInfo @event) {
MethodInfo? removeMethod = @event.GetRemoveMethod(true);

return removeMethod != null;
}

internal static IEnumerable<EventInfo> GetEventsRecursive(this Type type, BindingFlags bindingAttr) => GetMembersRecursive(
type,
bindingAttr,
Expand Down
4 changes: 2 additions & 2 deletions Implement.Net/TypeFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,11 @@ private Type GenerateNewType(Type interfaceType, ImmutableGenerationOptions opti
private static void BindEvent(TypeBuilder typeBuilder, EventInfo baseEvent, FieldInfo handlerField, bool markFinal) {
EventBuilder eventBuilder = typeBuilder.DefineEvent(baseEvent.Name, baseEvent.Attributes, baseEvent.EventHandlerType!);

if (baseEvent.CanAdd()) {
if (baseEvent.GetAddMethod(true) != null) {
eventBuilder.SetAddOnMethod(BindEventModificationMethod(typeBuilder, baseEvent, baseEvent.GetAddMethod(true)!, handlerField, Methods.IDynamicHandler.TryAddEventHandler, markFinal));
}

if (baseEvent.CanRemove()) {
if (baseEvent.GetRemoveMethod(true) != null) {
eventBuilder.SetRemoveOnMethod(BindEventModificationMethod(typeBuilder, baseEvent, baseEvent.GetRemoveMethod(true)!, handlerField, Methods.IDynamicHandler.TryRemoveEventHandler, markFinal));
}

Expand Down

0 comments on commit e51608a

Please sign in to comment.