internal void OpenWrite()
{
lock (Sync)
{
if (this.writeOpened)
{
Console.WriteLine("DataSeries::OpenWrite already write open");
return;
}
this.cache = this.cache ?? ReadCache();
if (this.bufferCount != 0 && this.cache[this.bufferCount - 1] != null)
{
this.writeKey = this.cache[this.bufferCount - 1];
this.writeKey.GetObjects();
}
else
{
if (this.position2 != -1)
{
this.writeKey = ReadKey(this.position2);
this.writeKey.number = this.bufferCount - 1;
this.writeKey.GetObjects();
}
else
{
this.writeKey = new DataKey(this.file)
{
number = 0,
changed = true
};
this.bufferCount = 1;
}
this.cache[this.writeKey.number] = this.writeKey;
}
if (this.cacheKey.position != -1)
this.file.DeleteKey(this.cacheKey, false, false);
this.cachePosition = -1;
this.file.WriteKey(this.key);
this.writeOpened = true;
}
}