public PhoneticStringProvider(IOptionsSnapshot <UserInterfaceOptions> options) { this.settings = options.Value.PhoneticSettings ?? new PhoneticSettings() { GroupSize = 4, LowerPrefix = null, UpperPrefix = "capital" }; if (this.settings.CharacterMappings != null && this.settings.CharacterMappings.Count > 0) { this.dictionary = new Dictionary <char, string>(); foreach (var kvp in this.settings.CharacterMappings) { char key = kvp.Key[0]; if (!this.dictionary.ContainsKey(key)) { this.dictionary.Add(key, kvp.Value); } } this.dictionary.Add(':', this.settings.PhoneticNameColon ?? "colon"); } foreach (var(key, value) in defaultDictionary) { if (!this.dictionary.ContainsKey(key)) { this.dictionary.Add(key, value); } } }
public PhoneticStringProvider(PhoneticSettings settings) { this.settings = settings ?? new PhoneticSettings() { GroupSize = 4, LowerPrefix = null, UpperPrefix = "capital" }; if (this.settings.GroupSize < 3) { this.settings.GroupSize = 3; } this.dictionary = new Dictionary <char, string>(); this.BuildCharacterMap(); }