Esempio n. 1
0
 public EventSubscription(
     IOpenModComponent ownerComponent,
     EventCallback callback,
     EventListenerAttribute attribute,
     string eventName,
     ILifetimeScope scope)
 {
     Owner    = new WeakReference(ownerComponent);
     Callback = callback;
     EventListenerAttribute = attribute;
     EventName = eventName;
     Scope     = scope;
 }
Esempio n. 2
0
 public EventSubscription(
     IOpenModComponent ownerComponent,
     Type eventListener,
     MethodBase method,
     EventListenerAttribute attribute,
     Type eventType,
     ILifetimeScope scope)
 {
     Owner         = new WeakReference(ownerComponent);
     EventListener = eventListener;
     Callback      = (serviceProvider, sender, @event) =>
     {
         var listener = serviceProvider.GetRequiredService(eventListener);
         return(method.InvokeWithTaskSupportAsync(listener, new[] { sender, @event }));
     };
     EventListenerAttribute = attribute;
     EventName = eventType.Name;
     EventType = eventType;
     Scope     = scope;
 }