var a = Smart.Format("{SomeKey}", new Dictionary<string, object>() { { "SomeKey", 999 } });
Output: "999"
var b = Smart.Format("{Some.Key}", new Dictionary<string, object>(){ { "Some.Key", 999 } } );
Output: "", Expected Output: "999"
It seems the presence of ., [, or ] cause the engine to check for a property within that path instead of trying to find an existing key. The best behavior would probably be for it to try both if a dictionary is keyed by strings.
To make matters slightly more complicated if I have a key of Count, I get the Property value. It seems to me that in the presence of a dictionary that the existence of a key should be checked first.
var b = Smart.Format("{Count}", new Dictionary<string, object>(){ { "Count", 999 } } );
Output: "1", Expected Output: "999"
With all the flexibility SmartFormat.Net has included, there are some restrictions. This one mentioned here should (an will) be mentioned in the docs: Don't use a dot in a Dictionary key.
Best explained with example:
var a = Smart.Format("{SomeKey}", new Dictionary<string, object>() { { "SomeKey", 999 } });
Output: "999"var b = Smart.Format("{Some.Key}", new Dictionary<string, object>(){ { "Some.Key", 999 } } );
Output: "", Expected Output: "999"It seems the presence of
.
,[
, or]
cause the engine to check for a property within that path instead of trying to find an existing key. The best behavior would probably be for it to try both if a dictionary is keyed by strings.To make matters slightly more complicated if I have a key of
Count
, I get the Property value. It seems to me that in the presence of a dictionary that the existence of a key should be checked first.var b = Smart.Format("{Count}", new Dictionary<string, object>(){ { "Count", 999 } } );
Output: "1", Expected Output: "999"