<PackageReference Include="Castle.Core" Version="4.2.1" />

DynamicDictionary

Wraps a IDictionary with a dynamic object to expose a bit better looking API. The implementation is trivial and assumes keys are Strings.
using System.Collections; using System.Collections.Generic; using System.Dynamic; using System.Linq; namespace Castle.Components.DictionaryAdapter { public class DynamicDictionary : DynamicObject { private readonly IDictionary dictionary; public DynamicDictionary(IDictionary dictionary) { this.dictionary = dictionary; } public override IEnumerable<string> GetDynamicMemberNames() { return from object key in dictionary.Keys select key.ToString(); } public override bool TryGetMember(GetMemberBinder binder, out object result) { result = dictionary[binder.Name]; return true; } public override bool TrySetMember(SetMemberBinder binder, object value) { dictionary[binder.Name] = value; return true; } } }