Esempio n. 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private java.util.Map<String, Object> extractVariables(org.camunda.bpm.engine.cdi.annotation.StartProcess startProcessAnnotation, javax.interceptor.InvocationContext ctx) throws Exception
        private IDictionary <string, object> extractVariables(StartProcess startProcessAnnotation, InvocationContext ctx)
        {
            VariableMap variables = new VariableMapImpl();

            foreach (System.Reflection.FieldInfo field in ctx.Method.DeclaringClass.DeclaredFields)
            {
                if (!field.isAnnotationPresent(typeof(ProcessVariable)) && !field.isAnnotationPresent(typeof(ProcessVariableTyped)))
                {
                    continue;
                }
                field.Accessible = true;

                string fieldName = null;

                ProcessVariable processStartVariable = field.getAnnotation(typeof(ProcessVariable));
                if (processStartVariable != null)
                {
                    fieldName = processStartVariable.value();
                }
                else
                {
                    ProcessVariableTyped processStartVariableTyped = field.getAnnotation(typeof(ProcessVariableTyped));
                    fieldName = processStartVariableTyped.value();
                }

                if (string.ReferenceEquals(fieldName, null) || fieldName.Length == 0)
                {
                    fieldName = field.Name;
                }
                object value = field.get(ctx.Target);
                variables.put(fieldName, value);
            }

            return(variables);
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
            public void doWith(System.Reflection.MethodInfo method)
            {
                State state = AnnotationUtils.getAnnotation(method, typeof(State));

                string processName = component.processKey();

                if (StringUtils.hasText(state.process()))
                {
                    processName = state.process();
                }

                string stateName = state.state();

                if (!StringUtils.hasText(stateName))
                {
                    stateName = state.value();
                }

                Assert.notNull(stateName, "You must provide a stateName!");

                IDictionary <int, string> vars = new Dictionary <int, string>();

                Annotation[][] paramAnnotationsArray = method.ParameterAnnotations;

                int ctr         = 0;
                int pvMapIndex  = -1;
                int procIdIndex = -1;

                foreach (Annotation[] paramAnnotations in paramAnnotationsArray)
                {
                    ctr += 1;

                    foreach (Annotation pa in paramAnnotations)
                    {
                        if (pa is ProcessVariable)
                        {
                            ProcessVariable pv     = (ProcessVariable)pa;
                            string          pvName = pv.value();
                            vars[ctr] = pvName;
                        }
                        else if (pa is ProcessVariables)
                        {
                            pvMapIndex = ctr;
                        }
                        else if (pa is ProcessId)
                        {
                            procIdIndex = ctr;
                        }
                    }
                }

                ActivitiStateHandlerRegistration registration = new ActivitiStateHandlerRegistration(vars, method, bean, stateName, beanName, pvMapIndex, procIdIndex, processName);

                outerInstance.registry.registerActivitiStateHandler(registration);
            }