mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
c72455508b
* Initial plan * Add test classes for extension methods Co-authored-by: crickman <66376200+crickman@users.noreply.github.com> * Fix test issues and document bug in ExpandoObjectExtensions Co-authored-by: crickman <66376200+crickman@users.noreply.github.com> * Address code review feedback - shorten Skip messages and add explanatory comments Co-authored-by: crickman <66376200+crickman@users.noreply.github.com> * Replace Fields.ToDictionary with GetField calls and fix ExpandoObjectExtensions bug Co-authored-by: crickman <66376200+crickman@users.noreply.github.com> * Update dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/Extensions/DataValueExtensionsTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/Extensions/DataValueExtensionsTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Remove unused using statement from DialogBaseExtensionsTests Co-authored-by: crickman <66376200+crickman@users.noreply.github.com> * Add proper WrapWithBot tests using AdaptiveDialog and OnActivity Co-authored-by: crickman <66376200+crickman@users.noreply.github.com> * Cleanup * Better * Better * One more test --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: crickman <66376200+crickman@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Chris Rickman <crickman@microsoft.com>
29 lines
835 B
C#
29 lines
835 B
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System.Collections.Generic;
|
|
using System.Dynamic;
|
|
using System.Linq;
|
|
using Microsoft.PowerFx.Types;
|
|
|
|
namespace Microsoft.Agents.AI.Workflows.Declarative.Extensions;
|
|
|
|
internal static class ExpandoObjectExtensions
|
|
{
|
|
public static RecordType ToRecordType(this ExpandoObject value)
|
|
{
|
|
RecordType recordType = RecordType.Empty();
|
|
|
|
foreach (KeyValuePair<string, object?> property in value)
|
|
{
|
|
recordType = recordType.Add(property.Key, property.Value.GetFormulaType());
|
|
}
|
|
|
|
return recordType;
|
|
}
|
|
|
|
public static RecordValue ToRecord(this ExpandoObject value) =>
|
|
FormulaValue.NewRecordFromFields(
|
|
value.Select(
|
|
property => new NamedValue(property.Key, property.Value.ToFormula())));
|
|
}
|