System.Activities.Presentation.NonTextualExpressionMorphHelper.TryMorphExpression C# (CSharp) Method

TryMorphExpression() public method

public TryMorphExpression ( ActivityWithResult expression, bool isLocationExpression, Type newType, System.Activities.Presentation.EditingContext context, ActivityWithResult &newExpression ) : bool
expression ActivityWithResult
isLocationExpression bool
newType Type
context System.Activities.Presentation.EditingContext
newExpression ActivityWithResult
return bool
        public override bool TryMorphExpression(ActivityWithResult expression, bool isLocationExpression, Type newType, 
            EditingContext context, out ActivityWithResult newExpression)
        {
            Fx.Assert(expression != null, "Original expression shouldn't be null in morph helper");
            Fx.Assert(context != null, "EditingContext shouldn't be null in morph helper");
            newExpression = null;
            if (expression.ResultType == newType && 
                (ExpressionHelper.IsGenericLocationExpressionType(expression) == isLocationExpression))
            {
                newExpression = expression;
                return true;
            }

            if (context != null)
            {
                string expressionEditor = ExpressionHelper.GetRootEditorSetting(context.Services.GetService<ModelTreeManager>(), WorkflowDesigner.GetTargetFramework(context));
                ParserContext parserContext = new ParserContext();
                string expressionText = ExpressionHelper.GetExpressionString(expression, parserContext);
                if (!string.IsNullOrEmpty(expressionEditor))
                {
                    return ExpressionTextBox.TryConvertFromString(expressionEditor, expressionText, isLocationExpression, newType, out newExpression);
                }
            }

            return false;
        }
    }
NonTextualExpressionMorphHelper