FormatWith icon indicating copy to clipboard operation
FormatWith copied to clipboard

Add support for indexers (support for Arrays/Lists/Dictionaries/etc)

Open crozone opened this issue 4 years ago • 1 comments

At present, FormatWith supports basic property navigations in parameter keys. However, it does not support combining this with indexers to navigate into objects arrays, lists, or dictionaries.

For example, this is currently supported:

string result = "{foo.bar}".FormatWith(new 
{ 
    foo = new { bar = "test" }
});

However, we should be able to do this:

string result = "{foo[\"bar\"].Length}".FormatWith(new 
{
    foo = new Dictionary<string, string> { ["bar"] = "test" }
});

This is the code that will need to be changed:

https://github.com/crozone/FormatWith/blob/3fbb5ee16b5db299ead5d8851becba8b08021b86/FormatWith/Internal/FormatWithMethods.cs#L320-L361

crozone avatar Jun 23 '21 07:06 crozone

This will potentially solve https://github.com/crozone/FormatWith/issues/23.

crozone avatar Jun 23 '21 07:06 crozone