зеркало из https://github.com/microsoft/Power-Fx.git
Environment variables helper (#2673)
Issue https://github.com/microsoft/Power-Fx/issues/2416.
This commit is contained in:
Родитель
9531d76c40
Коммит
062a89718b
|
@ -43,11 +43,11 @@ namespace Microsoft.PowerFx.Types
|
|||
|
||||
protected override bool TryGetField(FormulaType fieldType, string fieldName, out FormulaValue result)
|
||||
{
|
||||
if (Type.TryGetFieldType(fieldName, out var compileTimeType))
|
||||
if (Type.TryGetFieldType(fieldName, out var logical, out var compileTimeType))
|
||||
{
|
||||
// Only return field which were specified via the expectedType (IE RecordType),
|
||||
// because inner record value may have more fields than the expected type.
|
||||
if (compileTimeType == fieldType && _fields.TryGetValue(fieldName, out result))
|
||||
if (compileTimeType == fieldType && _fields.TryGetValue(logical, out result))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ using Microsoft.PowerFx.Core.Functions;
|
|||
using Microsoft.PowerFx.Core.Texl.Builtins;
|
||||
using Microsoft.PowerFx.Functions;
|
||||
using Microsoft.PowerFx.Interpreter;
|
||||
using Microsoft.PowerFx.Types;
|
||||
|
||||
namespace Microsoft.PowerFx
|
||||
{
|
||||
|
@ -22,6 +23,12 @@ namespace Microsoft.PowerFx
|
|||
symbolTable.AddFunction(function.GetTexlFunction());
|
||||
}
|
||||
|
||||
public static void AddEnvironmentVariables(this SymbolValues symbolValues, RecordValue recordValue)
|
||||
{
|
||||
var variablesRecordValue = FormulaValue.NewRecordFromFields(new NamedValue("Variables", recordValue));
|
||||
symbolValues.Add("Environment", variablesRecordValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable a Set() function which allows scripts to do <see cref="RecalcEngine.UpdateVariable(string, Types.FormulaValue, SymbolProperties)"/>.
|
||||
/// </summary>
|
||||
|
|
|
@ -124,7 +124,7 @@ namespace Microsoft.PowerFx.Core.Tests.Helpers
|
|||
|
||||
public DType Schema => throw new NotImplementedException();
|
||||
|
||||
public BidirectionalDictionary<string, string> DisplayNameMapping => throw new NotImplementedException();
|
||||
public BidirectionalDictionary<string, string> DisplayNameMapping => new BidirectionalDictionary<string, string>();
|
||||
|
||||
public BidirectionalDictionary<string, string> PreviousDisplayNameMapping => throw new NotImplementedException();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче