public static ISubscription <T> CreateSubscription(ISubscriptionKey <T> subscriptionRequest, IProvideHandlerDispatchDelegateCaches handlerDispatchDelegateCacheProvider) { ISubscription <T> result = new Subscription <T>(subscriptionRequest, handlerDispatchDelegateCacheProvider); subscriptionRequest.MarkAsUsed(); return(result); }
internal Subscription(ISubscriptionKey <T> subRequestKey, IProvideHandlerDispatchDelegateCaches handlerDispatchDelegateCacheProvider) { OwnerPropId = subRequestKey.OwnerPropId; SubscriptionKind = subRequestKey.SubscriptionKind; SubscriptionPriorityGroup = subRequestKey.SubscriptionPriorityGroup; //SubscriptionTargetKind = sKey.SubscriptionTargetKind; switch (subRequestKey.SubscriptionKind) { case SubscriptionKind.TypedHandler: { Target_Wrk = subRequestKey.Target_Wrk; //new WeakRefKey(subRequestKey.Target); Delegate proxyDelegate = handlerDispatchDelegateCacheProvider.DelegateProxyCache.GetOrAdd(new MethodSubscriptionKind(subRequestKey.Method, subRequestKey.SubscriptionKind)); HandlerProxy = proxyDelegate; Type targetType = subRequestKey.Target.GetType(); TypePair tp = new TypePair(targetType, typeof(T)); CallPcTypedEventSubscriberDelegate callTheListenerDel = handlerDispatchDelegateCacheProvider.CallPcTypedEventSubsCache.GetOrAdd(tp); PcTypedHandlerDispatcher = callTheListenerDel; MethodName = HandlerProxy.Method.Name; break; } //case SubscriptionKind.GenHandler: // break; //case SubscriptionKind.ObjHandler: // break; //case SubscriptionKind.StandardHandler: // break; //case SubscriptionKind.TypedAction: // { // throw new NotImplementedException("Comming soon."); // } //case SubscriptionKind.ObjectAction: // break; //case SubscriptionKind.ActionNoParams: // break; //case SubscriptionKind.LocalBinding: // break; default: throw new InvalidOperationException($"The SubscriptionKind: {SubscriptionKind} is not recognized or is not supported."); } }