using System; using System.Collections.Generic; namespace OnDeviceAgent.AgentCore { public sealed class MarkdownPropertyAccessor : IToolPropertyAccessor { readonly Dictionary> m_ByTool = new Dictionary>(StringComparer.OrdinalIgnoreCase); public MarkdownPropertyAccessor(IReadOnlyList defs) { if (defs == null) return; foreach (var d in defs) { var k = string.IsNullOrWhiteSpace(d.HandlerName) ? d.Name : d.HandlerName; if (!string.IsNullOrWhiteSpace(k)) m_ByTool[k.Trim()] = d.Properties; } } public string Get(string toolName, string key) => TryGet(toolName, key, out var v) ? v : string.Empty; public bool TryGet(string toolName, string key, out string value) { value = string.Empty; if (string.IsNullOrWhiteSpace(toolName) || string.IsNullOrWhiteSpace(key)) return false; return m_ByTool.TryGetValue(toolName.Trim(), out var p) && p != null && p.TryGetValue(key, out value); } } }