mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
* 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>
41 lines
1.6 KiB
C#
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}"),
|
|
};
|
|
}
|
|
}
|