csharpier
csharpier copied to clipboard
Generics with object creation needs some work
var someGeneric____________________________________ = new DictionaryHelper<
string,
ModelState
>()
{
Creator = () => new ModelStateDictionary(),
Comparer = StringComparer.OrdinalIgnoreCase,
SampleKeys = new string[] { "foo", "bar", "baz", "quux", "QUUX" },
SampleValues = new ModelState[]
{
new ModelState(),
new ModelState(),
new ModelState(),
new ModelState(),
new ModelState()
},
ThrowOnKeyNotFound = false
};
I think I'd rather have the generic types in new
never broken on several lines -- or only as a last resort if someone writes a new expression that can't stand on a line by itself (!?!).
I'd write the example above as:
var someGeneric____________________________________ =
new DictionaryHelper<string, ModelState>()
{
Creator = () => new ModelStateDictionary(),
Comparer = StringComparer.OrdinalIgnoreCase,
SampleKeys = new string[] { "foo", "bar", "baz", "quux", "QUUX" },
SampleValues = new ModelState[]
{
new ModelState(),
new ModelState(),
new ModelState(),
new ModelState(),
new ModelState(),
},
ThrowOnKeyNotFound = false,
};