1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //----------------------------------------------------------------
5 namespace System.Activities.Presentation
8 using System.Activities.Presentation.Expressions;
9 using System.Activities.Presentation.Model;
10 using System.Activities.Presentation.Services;
11 using System.Activities.Presentation.View;
12 using System.Collections.Generic;
16 using Microsoft.VisualBasic.Activities;
18 //This serves as expression morph helper for following non-textual expressions:
20 //2) VariableValue<T>/VariableReference<T>
21 //The helper will morph these expressions to what specified at root object by ExpressionActivityEditor attached property
22 class NonTextualExpressionMorphHelper : ExpressionMorphHelper
24 public override bool TryMorphExpression(ActivityWithResult expression, bool isLocationExpression, Type newType,
25 EditingContext context, out ActivityWithResult newExpression)
27 Fx.Assert(expression != null, "Original expression shouldn't be null in morph helper");
28 Fx.Assert(context != null, "EditingContext shouldn't be null in morph helper");
30 if (expression.ResultType == newType &&
31 (ExpressionHelper.IsGenericLocationExpressionType(expression) == isLocationExpression))
33 newExpression = expression;
39 string expressionEditor = ExpressionHelper.GetRootEditorSetting(context.Services.GetService<ModelTreeManager>(), WorkflowDesigner.GetTargetFramework(context));
40 ParserContext parserContext = new ParserContext();
41 string expressionText = ExpressionHelper.GetExpressionString(expression, parserContext);
42 if (!string.IsNullOrEmpty(expressionEditor))
44 return ExpressionTextBox.TryConvertFromString(expressionEditor, expressionText, isLocationExpression, newType, out newExpression);