Files
agent-framework/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/CodeGen/ParseValueTemplateCode.cs
T
75a8335af5 .NET - [Breaking]: Update Declarative Object Model + Dependencies (#3017)
* Builds locally and tests pass

* Fix typo

* Reverted nuget config change to remove internal feed and map to new public object model package with renames.

* Renaming Bot object model in additional sample.

---------

Co-authored-by: Peter Ibekwe <peibekwe@microsoft.com>
2026-01-28 20:00:37 +00:00

41 lines
1.6 KiB
C#

// Copyright (c) Microsoft. All rights reserved.
using System.Linq;
using Microsoft.Agents.ObjectModel;
using Microsoft.Shared.Diagnostics;
namespace Microsoft.Agents.AI.Workflows.Declarative.CodeGen;
internal partial class ParseValueTemplate
{
public ParseValueTemplate(ParseValue model)
{
this.Model = this.Initialize(model);
this.Variable = Throw.IfNull(this.Model.Variable);
}
public ParseValue Model { get; }
public PropertyPath Variable { get; }
private string GetVariableType()
{
return GetVariableType(this.Model.ValueType);
static string GetVariableType(DataType? dataType) =>
dataType switch
{
null => "null",
StringDataType => "typeof(string)",
BooleanDataType => "typeof(bool)",
FloatDataType => "typeof(double)",
NumberDataType => "typeof(decimal)",
DateTimeDataType => "typeof(DateTime)",
DateDataType => "typeof(DateTime)",
TimeDataType => "typeof(TimeSpan)",
RecordDataType recordType => $"\nVariableType.Record(\n{string.Join(",\n ", recordType.Properties.Select(property => @$"( ""{property.Key}"", {GetVariableType(property.Value.Type)} )"))})",
TableDataType tableType => $"\nVariableType.Record(\n{string.Join(",\n ", tableType.Properties.Select(property => @$"( ""{property.Key}"", {GetVariableType(property.Value.Type)} )"))})",
_ => throw new DeclarativeModelException($"Unsupported data type: {dataType}"),
};
}
}