Xamarin Public Jenkins (auto-signing) e79aa3c0ed Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
2016-08-03 10:59:49 +00:00

59 lines
2.4 KiB
C#

//----------------------------------------------------------------
// <copyright company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//----------------------------------------------------------------
namespace Microsoft.Activities.Presentation
{
using System.Activities.Expressions;
using System.Activities.Presentation.Expressions;
using System.Activities.Presentation.Model;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Versioning;
using Microsoft.VisualBasic.Activities;
internal static class ExpressionSettingHelper
{
internal static readonly string VBExpressionLanguageName = (new VisualBasicValue<string>() as ITextExpression).Language;
[SuppressMessage("Reliability", "Reliability101", Justification = "We can't use Fx.Assert here since this is not a framework assembly.")]
internal static string GetRootEditorSetting(ModelTreeManager modelTreeManager, FrameworkName targetFramework)
{
Debug.Assert(modelTreeManager != null, "modelTreeManager is null.");
Debug.Assert(targetFramework != null, "targetFramework is null.");
string globalEditorSetting = null;
if (Is45OrHigher(targetFramework))
{
if (modelTreeManager != null)
{
ModelItem rootItem = modelTreeManager.Root;
if (rootItem != null)
{
object root = rootItem.GetCurrentValue();
globalEditorSetting = ExpressionActivityEditor.GetExpressionActivityEditor(root);
if (string.IsNullOrEmpty(globalEditorSetting))
{
globalEditorSetting = VBExpressionLanguageName;
}
}
}
}
else
{
// When the target framework is less than 4.5, the root setting is ignored and always return VB
globalEditorSetting = VBExpressionLanguageName;
}
return globalEditorSetting;
}
private static bool Is45OrHigher(FrameworkName frameworkName)
{
return frameworkName.Version.Major > 4 || (frameworkName.Version.Major == 4 && frameworkName.Version.Minor >= 5);
}
}
}