Beispiel #1
0
 public SharedPtrCollection(CreateWrapperDelegate createWrapper, CreateHeapSharedPtrDelegate createHeapSharedPtr, DeleteHeapSharedPtrDelegate deleteHeapSharedPtr, ProcessWrapperObjectDelegate overrideProcessWrapperDelegate = null)
 {
     this.createWrapper       = createWrapper;
     this.createHeapSharedPtr = createHeapSharedPtr;
     this.deleteHeapSharedPtr = deleteHeapSharedPtr;
     if (overrideProcessWrapperDelegate == null)
     {
         ProcessWrapperCallback = new ProcessWrapperObjectDelegate(processWrapperObject);
     }
     else
     {
         ProcessWrapperCallback = overrideProcessWrapperDelegate;
     }
 }
            static CachedWrapperDelegate()
            {
                // This type makes the following assumption: TActionDelegate = Action<TParam> !

                // Get the Action<T> WrapHelper.WrapAction<T>(Action<T> value) methodinfo
                var wrapActionMethod = typeof(KafkaProduceSyncDeliveryHandlerIntegration)
                                       .GetMethod(nameof(WrapAction), BindingFlags.Public | BindingFlags.Static);

                // Create the generic method using the inner generic types of TActionDelegate => TParam
                wrapActionMethod = wrapActionMethod.MakeGenericMethod(typeof(TActionDelegate).GetGenericArguments());

                // With Action<TParam> WrapHelper.WrapAction<TParam>(Action<TParam> value) method info we create a delegate
                _createWrapper = (CreateWrapperDelegate)wrapActionMethod.CreateDelegate(typeof(CreateWrapperDelegate));
            }