Exemplo n.º 1
0
        private ICompiledExpressionRoot GetCompiledExpressionRoot()
        {
            if (this.rootInstance != null && this.rootInstance.Activity != null)
            {
                ICompiledExpressionRoot compiledExpressionRoot;
                Activity rootActivity = this.rootInstance.Activity;

                if (QualifiedId.TryGetElementFromRoot(rootActivity, this.compiledRootActivityQualifiedId, out Activity compiledRootActivity) &&
                    QualifiedId.TryGetElementFromRoot(rootActivity, this.expressionActivityQualifiedId, out Activity expressionActivity))
                {
                    if (CompiledExpressionInvoker.TryGetCompiledExpressionRoot(expressionActivity, compiledRootActivity, out compiledExpressionRoot))
                    {
                        //
                        // Revalidate to make sure we didn't hit an ID shift
                        if (compiledExpressionRoot.CanExecuteExpression(this.expressionText, true /* this is always a reference */, this.locationReferences, out this.expressionId))
                        {
                            return(compiledExpressionRoot);
                        }
                    }
                }
                //
                // We were valid when this location was generated so an ID shift occurred (likely due to a dynamic update)
                // Need to search all of the ICERs for one that can execute this expression.
                if (FindCompiledExpressionRoot(rootActivity, out compiledExpressionRoot))
                {
                    return(compiledExpressionRoot);
                }
            }
            throw FxTrace.Exception.AsError(new InvalidOperationException(SR.UnableToLocateCompiledLocationContext(this.expressionText)));
        }
Exemplo n.º 2
0
        private bool FindCompiledExpressionRoot(Activity activity, out ICompiledExpressionRoot compiledExpressionRoot)
        {
            if (CompiledExpressionInvoker.TryGetCompiledExpressionRoot(activity, this.forImplementation, out compiledExpressionRoot))
            {
                if (compiledExpressionRoot.CanExecuteExpression(this.expressionText, true /* this is always a reference */, this.locationReferences, out this.expressionId))
                {
                    return(true);
                }
            }

            foreach (Activity containedActivity in WorkflowInspectionServices.GetActivities(activity))
            {
                if (FindCompiledExpressionRoot(containedActivity, out compiledExpressionRoot))
                {
                    return(true);
                }
            }

            compiledExpressionRoot = null;
            return(false);
        }