Exemplo n.º 1
0
    public static TService GetRequiredService <TService>(this TelegramService telegramService)
    {
        var serviceScope    = InjectionUtil.GetScope();
        var serviceProvider = serviceScope.ServiceProvider;
        var resolvedService = serviceProvider.GetRequiredService <TService>();

        return(resolvedService);
    }
Exemplo n.º 2
0
        public override void performOperationStep(DeploymentOperation operationContext)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.application.AbstractProcessApplication processApplication = operationContext.getAttachment(Attachments.PROCESS_APPLICATION);
            AbstractProcessApplication processApplication = operationContext.getAttachment(Attachments.PROCESS_APPLICATION);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String paName = processApplication.getName();
            string paName = processApplication.Name;

            Type paClass = processApplication.GetType();

            System.Reflection.MethodInfo preUndeployMethod = InjectionUtil.detectAnnotatedMethod(paClass, typeof(PreUndeploy));

            if (preUndeployMethod == null)
            {
                LOG.debugPaLifecycleMethodNotFound(CALLBACK_NAME, paName);
                return;
            }

            LOG.debugFoundPaLifecycleCallbackMethod(CALLBACK_NAME, paName);

            // resolve injections
            object[] injections = InjectionUtil.resolveInjections(operationContext, preUndeployMethod);

            try
            {
                // perform the actual invocation
                preUndeployMethod.invoke(processApplication, injections);
            }
            catch (System.ArgumentException e)
            {
                throw LOG.exceptionWhileInvokingPaLifecycleCallback(CALLBACK_NAME, paName, e);
            }
            catch (IllegalAccessException e)
            {
                throw LOG.exceptionWhileInvokingPaLifecycleCallback(CALLBACK_NAME, paName, e);
            }
            catch (InvocationTargetException e)
            {
                Exception cause = e.InnerException;
                if (cause is Exception)
                {
                    throw (Exception)cause;
                }
                else
                {
                    throw LOG.exceptionWhileInvokingPaLifecycleCallback(CALLBACK_NAME, paName, e);
                }
            }
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected void invokePostDeploy(final org.camunda.bpm.application.ProcessApplicationInterface processApplication) throws ClassNotFoundException, org.jboss.msc.service.StartException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
        protected internal virtual void invokePostDeploy(ProcessApplicationInterface processApplication)
        {
            Type paClass = getPaClass(postDeployDescription);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final Method postDeployMethod = org.camunda.bpm.container.impl.deployment.util.InjectionUtil.detectAnnotatedMethod(paClass, org.camunda.bpm.application.PostDeploy.class);
            System.Reflection.MethodInfo postDeployMethod = InjectionUtil.detectAnnotatedMethod(paClass, typeof(PostDeploy));

            if (postDeployMethod != null)
            {
                try
                {
                    processApplication.execute(new CallableAnonymousInnerClass(this, processApplication, postDeployMethod));
                }
                catch (Exception e)
                {
                    throw new StartException("Exception while invoking the @PostDeploy method ", e);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// AddBinding 之前执行的 AOT 方法
        /// </summary>
        virtual protected void OnBeforeAddBinding(IBinder source, ref IBinding binding)
        {
            // 由于 AOT 委托在 Storing 方法过滤空 binding 之后才执行,所以这里就不重复检查了
            int length = binding.valueList.Count;

            for (int i = 0; i < length; i++)
            {
                if (binding.valueList[i] is Type)
                {
                    var value = Resolve(binding.valueList[i] as Type);
                    binding.To(value);
                }
                else
                {
                    // 如果当前 binder 中没有重复的值才进行注入(避免重复注入)
                    if (!InjectionUtil.IsExistOnBinder(binding.valueList[i], binder))
                    {
                        Inject(binding.valueList[i]);
                    }
                }
            }
        }
 /// <summary>
 /// Does dependency injection on a StateMachineBehaviour.
 /// </summary>
 /// <param name="script">Target script of the injection.</param>
 public static void Inject(this StateMachineBehaviour script)
 {
     InjectionUtil.Inject(script);
 }
 /// <summary>
 /// Does dependency injection on a MonoBehaviour.
 /// </summary>
 /// <param name="script">Target script of the injection.</param>
 public static void Inject(this MonoBehaviour script)
 {
     InjectionUtil.Inject(script);
 }