public string Format(string format, Density density) { string workingFormat = format; var massProvider = new CorrectPluralityFormatProvider(new Mass(density.Amount, density.Mass.Unit)); foreach (var m in placeholder1.Matches(format).Cast<Match>()) workingFormat = workingFormat.Replace(m.Value, String.Format(massProvider, m.Value, null, density.Mass.Unit)); var volumeProvider = new CorrectPluralityFormatProvider(new Volume(UnitPlurality.Single.Example, density.Volume.Unit)); foreach (var m in placeholder2.Matches(format).Cast<Match>()) workingFormat = workingFormat.Replace(m.Value, String.Format(volumeProvider, m.Value, null, null, density.Volume.Unit)); return String.Format(workingFormat, density.Amount, null, null); }
public string Format(string format, Density density) { var provider = new CorrectPluralityFormatProvider(density); return String.Format(provider, format, density.Amount, density.Unit); }