static ValueTaskContinuationGenerator()
        {
            DynamicMethod continuationMethod = IntegrationMapper.CreateAsyncEndMethodDelegate(typeof(TIntegration), typeof(TTarget), typeof(object));

            if (continuationMethod != null)
            {
                _continuation = (Func <TTarget, object, Exception, CallTargetState, object>)continuationMethod.CreateDelegate(typeof(Func <TTarget, object, Exception, CallTargetState, object>));
            }
        }
コード例 #2
0
        static TaskContinuationGenerator()
        {
            var result = IntegrationMapper.CreateAsyncEndMethodDelegate(typeof(TIntegration), typeof(TTarget), typeof(object));

            if (result.Method != null)
            {
                _continuation    = (Func <TTarget, object, Exception, CallTargetState, object>)result.Method.CreateDelegate(typeof(Func <TTarget, object, Exception, CallTargetState, object>));
                _preserveContext = result.PreserveContext;
            }
        }
        static ValueTaskContinuationGenerator()
        {
            var result = IntegrationMapper.CreateAsyncEndMethodDelegate(typeof(TIntegration), typeof(TTarget), typeof(TResult));

            if (result.Method != null)
            {
                _continuation    = (ContinuationMethodDelegate)result.Method.CreateDelegate(typeof(ContinuationMethodDelegate));
                _preserveContext = result.PreserveContext;
            }
        }
コード例 #4
0
        static TaskContinuationGenerator()
        {
            DynamicMethod continuationMethod = IntegrationMapper.CreateAsyncEndMethodDelegate(typeof(TIntegration), typeof(TTarget), typeof(TResult));

            if (continuationMethod != null)
            {
                _continuation = (Func <TTarget, TResult, Exception, CallTargetState, TResult>)continuationMethod.CreateDelegate(typeof(Func <TTarget, TResult, Exception, CallTargetState, TResult>));
            }

            _continuationAction = new Func <Task <TResult>, object, TResult>(ContinuationAction);
        }
    static EndMethodHandler()
    {
        Type returnType = typeof(TReturn);

        try
        {
            DynamicMethod dynMethod = IntegrationMapper.CreateEndMethodDelegate(typeof(TIntegration), typeof(TTarget), returnType);
            if (dynMethod != null)
            {
                _invokeDelegate = (InvokeDelegate)dynMethod.CreateDelegate(typeof(InvokeDelegate));
            }
        }
        catch (Exception ex)
        {
            throw new CallTargetInvokerException(ex);
        }

        if (returnType.IsGenericType)
        {
            Type genericReturnType = returnType.GetGenericTypeDefinition();
            if (typeof(Task).IsAssignableFrom(returnType))
            {
                // The type is a Task<>
                _continuationGenerator = (ContinuationGenerator <TTarget, TReturn>)Activator.CreateInstance(typeof(TaskContinuationGenerator <, , ,>).MakeGenericType(typeof(TIntegration), typeof(TTarget), returnType, ContinuationsHelper.GetResultType(returnType)));
            }
#if NETCOREAPP3_1_OR_GREATER
            else if (genericReturnType == typeof(ValueTask <>))
            {
                // The type is a ValueTask<>
                _continuationGenerator = (ContinuationGenerator <TTarget, TReturn>)Activator.CreateInstance(typeof(ValueTaskContinuationGenerator <, , ,>).MakeGenericType(typeof(TIntegration), typeof(TTarget), returnType, ContinuationsHelper.GetResultType(returnType)));
            }
#endif
        }
        else
        {
            if (returnType == typeof(Task))
            {
                // The type is a Task
                _continuationGenerator = new TaskContinuationGenerator <TIntegration, TTarget, TReturn>();
            }
#if NETCOREAPP3_1_OR_GREATER
            else if (returnType == typeof(ValueTask))
            {
                // The type is a ValueTask
                _continuationGenerator = new ValueTaskContinuationGenerator <TIntegration, TTarget, TReturn>();
            }
#endif
        }
    }
コード例 #6
0
        static DuckTypeMethodCallComparisonBenchmark()
        {
            foreach (var obj in GetObjects())
            {
                obj.DuckCast <IMethodRunner>();
                obj.DuckCast <MethodRunnerClass>();
                obj.DuckCast <AbstractMethodRunner>();
                obj.DuckCast <ValuesCopy>();
            }

            _voidMethodIntegrationDelegate    = (InvokeDelegate)IntegrationMapper.CreateBeginMethodDelegate(typeof(VoidMethodIntegration), typeof(PropertyPublicObject), Type.EmptyTypes).CreateDelegate(typeof(InvokeDelegate));
            _returnMethodIntegrationDelegate  = (InvokeDelegate)IntegrationMapper.CreateBeginMethodDelegate(typeof(ReturnMethodIntegration), typeof(PropertyPublicObject), Type.EmptyTypes).CreateDelegate(typeof(InvokeDelegate));
            _getPropertiesIntegrationDelegate = (InvokeDelegate)IntegrationMapper.CreateBeginMethodDelegate(typeof(GetPropertiesIntegration), typeof(PropertyPublicObject), Type.EmptyTypes).CreateDelegate(typeof(InvokeDelegate));

            _voidMethodIDuckTypeIntegrationDelegate    = (InvokeDelegate)IntegrationMapper.CreateBeginMethodDelegate(typeof(VoidMethodIDuckTypeIntegration), typeof(PropertyPublicObject), Type.EmptyTypes).CreateDelegate(typeof(InvokeDelegate));
            _returnMethodIDuckTypeIntegrationDelegate  = (InvokeDelegate)IntegrationMapper.CreateBeginMethodDelegate(typeof(ReturnMethodIDuckTypeIntegration), typeof(PropertyPublicObject), Type.EmptyTypes).CreateDelegate(typeof(InvokeDelegate));
            _getPropertiesIDuckTypeIntegrationDelegate = (InvokeDelegate)IntegrationMapper.CreateBeginMethodDelegate(typeof(GetPropertiesIDuckTypeIntegration), typeof(PropertyPublicObject), Type.EmptyTypes).CreateDelegate(typeof(InvokeDelegate));
        }
コード例 #7
0
        public async Task <IActionResult> Detail(Guid id)
        {
            var integrationUid = id;

            if (integrationUid.IsEmptyGuid())
            {
                return(RedirectToAccessDenied());
            }

            var request  = new IntegrationReadRequest(CurrentUser.Id, integrationUid);
            var response = await _integrationService.GetIntegration(request);

            if (response.Status.IsNotSuccess)
            {
                return(RedirectToAccessDenied());
            }

            var model = IntegrationMapper.MapIntegrationDetailModel(response.Item);

            return(View(model));
        }
コード例 #8
0
        public IActionResult Create(Guid id)
        {
            var organizationUid = id;

            if (organizationUid.IsEmptyGuid())
            {
                organizationUid = CurrentUser.OrganizationUid;
            }

            var request  = new OrganizationReadRequest(CurrentUser.Id, organizationUid);
            var response = OrganizationService.GetOrganization(request);

            if (response.Status.IsNotSuccess)
            {
                return(RedirectToAccessDenied());
            }

            var model = IntegrationMapper.MapIntegrationCreateModel(organizationUid);

            return(View(model));
        }
 static BeginMethodHandler()
 {
     try
     {
         DynamicMethod dynMethod = IntegrationMapper.CreateBeginMethodDelegate(typeof(TIntegration), typeof(TTarget), new[] { typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4) });
         if (dynMethod != null)
         {
             _invokeDelegate = (InvokeDelegate)dynMethod.CreateDelegate(typeof(InvokeDelegate));
         }
     }
     catch (Exception ex)
     {
         throw new CallTargetInvokerException(ex);
     }
     finally
     {
         if (_invokeDelegate is null)
         {
             _invokeDelegate = (instance, arg1, arg2, arg3, arg4) => CallTargetState.GetDefault();
         }
     }
 }
コード例 #10
0
 static EndMethodHandler()
 {
     try
     {
         DynamicMethod dynMethod = IntegrationMapper.CreateEndMethodDelegate(typeof(TIntegration), typeof(TTarget));
         if (dynMethod != null)
         {
             _invokeDelegate = (InvokeDelegate)dynMethod.CreateDelegate(typeof(InvokeDelegate));
         }
     }
     catch (Exception ex)
     {
         throw new CallTargetInvokerException(ex);
     }
     finally
     {
         if (_invokeDelegate is null)
         {
             _invokeDelegate = (instance, exception, state) => CallTargetReturn.GetDefault();
         }
     }
 }
 static BeginMethodSlowHandler()
 {
     try
     {
         DynamicMethod dynMethod = IntegrationMapper.CreateSlowBeginMethodDelegate(typeof(TIntegration), typeof(TTarget));
         if (dynMethod != null)
         {
             _invokeDelegate = (InvokeDelegate)dynMethod.CreateDelegate(typeof(InvokeDelegate));
         }
     }
     catch (Exception ex)
     {
         throw new CallTargetInvokerException(ex);
     }
     finally
     {
         if (_invokeDelegate is null)
         {
             _invokeDelegate = (instance, arguments) => CallTargetState.GetDefault();
         }
     }
 }
コード例 #12
0
 static BeginMethodHandler()
 {
     try
     {
         DynamicMethod dynMethod = IntegrationMapper.CreateBeginMethodDelegate(typeof(TIntegration), typeof(TTarget), Array.Empty <Type>());
         if (dynMethod != null)
         {
             _invokeDelegate = (InvokeDelegate)dynMethod.CreateDelegate(typeof(InvokeDelegate));
         }
     }
     catch (Exception ex)
     {
         throw new CallTargetInvokerException(ex);
     }
     finally
     {
         if (_invokeDelegate is null)
         {
             _invokeDelegate = instance => CallTargetState.GetDefault();
         }
     }
 }