コード例 #1
0
        private void ParseEntry(TextReader reader, int lineNumber)
        {
            if (!reader.TryReadExpected("STR_"))
            {
                _logger.LogError(lineNumber, "Expected line to start with 'STR_'");
                return;
            }

            string identifier = reader.ReadString(4);

            string[] validIdentifiers = null;

            switch (_currentEntryType)
            {
            case LanguageEntryType.ObjectOverride:
                validIdentifiers = ObjectOverrideIdentifiers;
                break;

            case LanguageEntryType.ScenarioOverride:
                validIdentifiers = ScenarioOverrideIdentifiers;
                break;
            }

            if (validIdentifiers == null)
            {
                ushort index;
                if (!UInt16.TryParse(identifier, out index))
                {
                    _logger.LogError(lineNumber, $"String identifier must be between {UInt16.MinValue} and {UInt16.MaxValue}");
                    return;
                }
            }
            else
            {
                if (!validIdentifiers.Contains(identifier))
                {
                    _logger.LogError(lineNumber, $"Invalid identifier '{identifier}'");
                }
                if (!_groupItemIdentifiers.Add(identifier))
                {
                    _logger.LogWarning(lineNumber, $"Entry '{identifier}' already set.");
                }
            }

            ParseWhitespace(reader, lineNumber, 4);

            if (!reader.TryReadExpected(":"))
            {
                _logger.LogError(lineNumber, "Expected ':' after identifier");
            }

            string text = reader.ReadToEnd();
        }