// Copyright (c) Microsoft. All rights reserved.
using System.Collections.Generic;
using System.Text.Json;
using Microsoft.Extensions.AI;
namespace A2A;
///
/// Extension methods for A2A metadata dictionary.
///
internal static class A2AMetadataExtensions
{
///
/// Converts a dictionary of metadata to an .
///
/// The metadata dictionary to convert.
/// The converted , or null if the input is null or empty.
internal static AdditionalPropertiesDictionary? ToAdditionalProperties(this Dictionary? metadata)
{
if (metadata is not { Count: > 0 })
{
return null;
}
var additionalProperties = new AdditionalPropertiesDictionary();
foreach (var kvp in metadata)
{
additionalProperties[kvp.Key] = kvp.Value;
}
return additionalProperties;
}
}