Added position saving and loading feature to Accessor
This commit is contained in:
parent
463b053e25
commit
8b8a0c18f0
@ -189,5 +189,27 @@ namespace UniversalEditor
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
#region Position Saving and Loading
|
||||
private Stack<long> _positions = new Stack<long>();
|
||||
[DebuggerNonUserCode()]
|
||||
public void SavePosition()
|
||||
{
|
||||
_positions.Push(this.Position);
|
||||
}
|
||||
[DebuggerNonUserCode()]
|
||||
public void LoadPosition()
|
||||
{
|
||||
if (_positions.Count > 0) this.Position = _positions.Pop();
|
||||
}
|
||||
public void ClearLastPosition()
|
||||
{
|
||||
if (_positions.Count > 0) _positions.Pop();
|
||||
}
|
||||
public void ClearAllPositions()
|
||||
{
|
||||
if (_positions.Count > 0) _positions.Clear();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,13 +49,13 @@ namespace UniversalEditor.DataFormats.FileSystem.BinHex
|
||||
if (fsom == null) throw new ObjectModelNotSupportedException();
|
||||
|
||||
Reader reader = base.Accessor.Reader;
|
||||
reader.SavePosition();
|
||||
base.Accessor.SavePosition();
|
||||
|
||||
string line = reader.ReadLine();
|
||||
if (!(line.StartsWith("(This file must be converted with BinHex ") && line.EndsWith(")")))
|
||||
{
|
||||
if (mvarRequireWarningComment) throw new InvalidDataFormatException("File does not begin with BinHex warning comment");
|
||||
reader.LoadPosition();
|
||||
base.Accessor.LoadPosition();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -63,7 +63,7 @@ namespace UniversalEditor.DataFormats.FileSystem.BinHex
|
||||
line = line.Substring(0, line.Length - 1);
|
||||
mvarFormatVersion = new Version(line);
|
||||
}
|
||||
reader.ClearLastPosition();
|
||||
base.Accessor.ClearLastPosition();
|
||||
|
||||
string inputStr = reader.ReadStringToEnd();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user