Write the text file exactly like this:
Acme.*.MinimumPrice = 100
Acme.ProductA.MinimumPrice = 50
Acme.ProductB.MinimumPrice = 60
Acme.ProductC.DefaultColor = Blue
Divide it into a sequence of pairs / path:
foreach (var pair in File.ReadAllLines(configFileName)
.Select(l => l.Split('='))
.Select(a => new { Path = a[0], Value = a[1] }))
{
}
Now there are two possible interpretations of what you want to do. A string Acme.*.MinimumPricecan mean that for any search where there is no specific redefinition, for example Acme.Toadstool.MinimumPrice, we return 100- even if there is nothing in the file that refers to Toadstool. Or it may mean that it should return 100if there are other specific references in the file Toadstool.
, , , -, .
, , , , . .
, , Acme.*.MinimumPrice " MinimumPrice , ". , , , :
Acme.ProductA.MinimumPrice = 50
Acme.ProductB.MinimumPrice = 60
Acme.ProductC.DefaultColor = Blue
Acme.ProductC.MinimumPrice = 100
, , TryGetValue [], . , .
, - , , API, , . ( ), .