public virtual void Handle(MigratingInstanceParseContext parseContext,
                                   MigratingTransitionInstance transitionInstance, IList <JobEntity> elements)
        {
            foreach (var job in elements)
            {
                if (!IsAsyncContinuation(job))
                {
                    continue;
                }

                var targetScope = transitionInstance.TargetScope;
                if (targetScope != null)
                {
                    var targetJobDefinitionEntity =
                        parseContext.GetTargetJobDefinition(transitionInstance.TargetScope.Id, job.JobHandlerType);

                    var migratingJobInstance = new MigratingAsyncJobInstance(job, targetJobDefinitionEntity,
                                                                             transitionInstance.TargetScope);

                    transitionInstance.DependentJobInstance = migratingJobInstance;
                    parseContext.Submit(migratingJobInstance);
                }

                parseContext.Consume(job);
            }
        }
        public virtual void Handle(MigratingInstanceParseContext parseContext, IActivityInstance element)
        {
            MigratingActivityInstance migratingInstance = null;

            var       applyingInstruction     = parseContext.GetInstructionFor(element.ActivityId);
            ScopeImpl sourceScope             = null;
            ScopeImpl targetScope             = null;
            var       representativeExecution = parseContext.Mapping.GetExecution(element);

            if (element.Id.Equals(element.ProcessInstanceId))
            {
                sourceScope = parseContext.SourceProcessDefinition;
                targetScope = parseContext.TargetProcessDefinition;
            }
            else
            {
                sourceScope = (ScopeImpl)parseContext.SourceProcessDefinition.FindActivity(element.ActivityId);

                if (applyingInstruction != null)
                {
                    var activityId = applyingInstruction.TargetActivityId;
                    targetScope = (ScopeImpl)parseContext.TargetProcessDefinition.FindActivity(activityId);
                }
            }

            migratingInstance = parseContext.MigratingProcessInstance.AddActivityInstance(applyingInstruction, element,
                                                                                          sourceScope, targetScope, representativeExecution);

            var parentInstance = parseContext.GetMigratingActivityInstanceById(element.ParentActivityInstanceId);

            if (parentInstance != null)
            {
                //migratingInstance.setParent(parentInstance);
            }

            //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
            //ORIGINAL LINE: org.camunda.bpm.engine.impl.core.delegate.CoreActivityBehavior<object> sourceActivityBehavior = sourceScope.getActivityBehavior();
            var sourceActivityBehavior = sourceScope.ActivityBehavior;

            if (sourceActivityBehavior is IMigrationObserverBehavior)
            {
                ((IMigrationObserverBehavior)sourceActivityBehavior).OnParseMigratingInstance(parseContext,
                                                                                              migratingInstance);
            }

            parseContext.Submit(migratingInstance);

            ParseTransitionInstances(parseContext, migratingInstance);

            ParseDependentInstances(parseContext, migratingInstance);
        }