ParallelRoadTool/Utils/LocalizationManager.cs
/// <summary>
/// Deserializes a <see cref="NameList"/> from a given resource name inside the assembly
/// </summary>
/// <param name="resourceName"></param>
/// <returns></returns>
Deserializes a  from a given resource name inside the assembly
Deserializes a from a given resource name inside the assembly
private static NameList ReadNameList(string resourceName)
        {
            try
            {
                var serializer = new XmlSerializer(typeof(NameList));
                var assembly = Assembly.GetExecutingAssembly();
                using var stream = assembly.GetManifestResourceStream(resourceName);
                using var reader = new StreamReader(stream ?? throw new InvalidOperationException($"Can't load stream for file {resourceName}"));
                using var xmlStream = XmlReader.Create(reader);
                if (serializer.CanDeserialize(xmlStream))
                {
                    return (NameList)serializer.Deserialize(xmlStream);
                }
                else
                {
                    return null;
                }
            }
            catch (Exception e)
            {
                Log._DebugOnlyError($"[{nameof(LocalizationManager)}.{nameof(ApplyLocaleResources)}] ApplyLocaleResource(${resourceName}) failed.");
                Log.Exception(e);
                return null;
            }
        }
private static NameList ReadNameList ( string resourceName ) { try { var serializer = new XmlSerializer ( typeof ( NameList ) ) ; var assembly = Assembly . GetExecutingAssembly ( ) ; using var stream = assembly . GetManifestResourceStream ( resourceName ) ; using var reader = new StreamReader ( stream ?? throw new InvalidOperationException ( $" Can't load stream for file  { resourceName } " ) ) ; using var xmlStream = XmlReader . Create ( reader ) ; if ( serializer . CanDeserialize ( xmlStream ) ) { return ( NameList ) serializer . Deserialize ( xmlStream ) ; } else { return null ; } } catch ( Exception e ) { Log . _DebugOnlyError ( $" [ { nameof ( LocalizationManager ) } . { nameof ( ApplyLocaleResources ) } ] ApplyLocaleResource($ { resourceName } ) failed. " ) ; Log . Exception ( e ) ; return null ; } }
Deserializes a  from a given resource name inside the assembly
Deserializes a from a given resource name inside the assembly
// Log the exception and return false
None
resourceName
string
None