Успешно переписаны не полностью два файла

This commit is contained in:
2025-03-25 21:27:54 +03:00
parent 155d942a03
commit bf636c0f9c
23 changed files with 676 additions and 98 deletions
@@ -0,0 +1,41 @@
using System;
namespace mROA.CodegenTools
{
public abstract class LeadingTextSectionReader : ISectionReader
{
protected int _currentCaretPosition;
private string _tagLeading;
protected LeadingTextSectionReader(string tagLeading)
{
_tagLeading = tagLeading + " ";
}
protected int PassCaretToCloseSymbol()
{
_currentCaretPosition = TemplateText.IndexOf(">", _currentCaretPosition, StringComparison.Ordinal) + 1;
return _currentCaretPosition;
}
public string TemplateText { get; set; }
public int GetNextSectionIndex(int currentIndex)
{
_currentCaretPosition = Math.Max(currentIndex, _currentCaretPosition);
var index = TemplateText.IndexOf(_tagLeading, _currentCaretPosition, StringComparison.Ordinal);
_currentCaretPosition = index;
return index;
}
public abstract ITemplateSection ExtractSection(ref int index, TemplateDocument document);
protected string GetTagValue(int from, int to)
{
var realStart = from + 4;
var span = TemplateText.AsSpan();
var slice = span.Slice(realStart, to - realStart);
return new string(slice.ToArray());
}
}
}