1 //----------------------------------------------------------------
2 // <copyright company="Microsoft Corporation">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 //----------------------------------------------------------------
7 namespace Microsoft.Activities.Presentation
9 using System.Activities.Expressions;
10 using System.Activities.Presentation.Expressions;
11 using System.Activities.Presentation.Model;
12 using System.Diagnostics;
13 using System.Diagnostics.CodeAnalysis;
14 using System.Runtime.Versioning;
15 using Microsoft.VisualBasic.Activities;
17 internal static class ExpressionSettingHelper
19 internal static readonly string VBExpressionLanguageName = (new VisualBasicValue<string>() as ITextExpression).Language;
21 [SuppressMessage("Reliability", "Reliability101", Justification = "We can't use Fx.Assert here since this is not a framework assembly.")]
22 internal static string GetRootEditorSetting(ModelTreeManager modelTreeManager, FrameworkName targetFramework)
24 Debug.Assert(modelTreeManager != null, "modelTreeManager is null.");
25 Debug.Assert(targetFramework != null, "targetFramework is null.");
27 string globalEditorSetting = null;
28 if (Is45OrHigher(targetFramework))
30 if (modelTreeManager != null)
32 ModelItem rootItem = modelTreeManager.Root;
35 object root = rootItem.GetCurrentValue();
36 globalEditorSetting = ExpressionActivityEditor.GetExpressionActivityEditor(root);
37 if (string.IsNullOrEmpty(globalEditorSetting))
39 globalEditorSetting = VBExpressionLanguageName;
46 // When the target framework is less than 4.5, the root setting is ignored and always return VB
47 globalEditorSetting = VBExpressionLanguageName;
50 return globalEditorSetting;
53 private static bool Is45OrHigher(FrameworkName frameworkName)
55 return frameworkName.Version.Major > 4 || (frameworkName.Version.Major == 4 && frameworkName.Version.Minor >= 5);