From 195ac1037b3122749f9a2b381508347011878202 Mon Sep 17 00:00:00 2001 From: Lehonti Ramos Date: Wed, 6 Sep 2023 10:20:37 +0200 Subject: [PATCH] Simplified initialization of a dictionary --- src/XamlMath.Shared/DefaultTexFontParser.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/XamlMath.Shared/DefaultTexFontParser.cs b/src/XamlMath.Shared/DefaultTexFontParser.cs index 2c1f3865..de0b57a8 100644 --- a/src/XamlMath.Shared/DefaultTexFontParser.cs +++ b/src/XamlMath.Shared/DefaultTexFontParser.cs @@ -172,18 +172,18 @@ public IReadOnlyDictionary GetParameters() public IReadOnlyDictionary GetGeneralSettings() { - var result = new Dictionary(); - var generalSettings = rootElement.Element("GeneralSettings"); + if (generalSettings == null) throw new InvalidOperationException("Cannot find GeneralSettings element."); - result.Add("mufontid", generalSettings.AttributeInt32Value("mufontid")); - result.Add("spacefontid", generalSettings.AttributeInt32Value("spacefontid")); - result.Add("scriptfactor", generalSettings.AttributeDoubleValue("scriptfactor")); - result.Add("scriptscriptfactor", generalSettings.AttributeDoubleValue("scriptscriptfactor")); - - return result; + return new Dictionary + { + ["mufontid"] = generalSettings.AttributeInt32Value("mufontid"), + ["spacefontid"] = generalSettings.AttributeInt32Value("spacefontid"), + ["scriptfactor"] = generalSettings.AttributeDoubleValue("scriptfactor"), + ["scriptscriptfactor"] = generalSettings.AttributeDoubleValue("scriptscriptfactor"), + }; } public IReadOnlyDictionary> GetTextStyleMappings()