CPF/CPF.ReoGrid/Formula/ReplacableString.cs
2024-06-24 10:15:59 +08:00

58 lines
869 B
C#

using System;
using System.Text;
namespace CPF.ReoGrid.Formula
{
internal class ReplacableString
{
internal ReplacableString(string str)
{
this.original = str;
this.Restore();
}
internal int Offset
{
get
{
return this.offset;
}
}
public int Replace(int from, int len, string newstr)
{
this.sb.Remove(from, len);
this.sb.Insert(from, newstr);
int num = newstr.Length - len;
this.offset += num;
return num;
}
public override string ToString()
{
return this.sb.ToString();
}
public void Restore()
{
bool flag = this.sb == null;
if (flag)
{
this.sb = new StringBuilder(this.original, 256);
}
else
{
this.sb.Length = 0;
this.sb.Append(this.original);
}
this.offset = 0;
}
private string original;
private StringBuilder sb;
private int offset = 0;
}
}