private void CacheIndexTable() { if (cachedTable != null) { return; } if (node.TypedStreams.Contains(typeof(IndexTableTag).FullName)) { using (IDriverTypedStream stream = node.GetTypedStream(OpenMode.Read, typeof(IndexTableTag).FullName)) { cachedTable = ((IndexTableTag)(stream.UsesRaw ? Common.DeserializeFromArray(stream.Read(0) as byte[]) : stream.Read(0))).Table; } } }
/// <summary> /// Caches base node, if not already cached. /// </summary> private ManagedNode CacheBase() { // We must quickly open default tag stream, if it exists. using (IDriverTypedStream stream = node.GetTypedStream(OpenMode.ReadWrite, typeof(BaseNodeTag).FullName)) { // Make sure we proceed this read only once. if (stream == null) { return(null); } // Now we find the type. BaseNodeTag tag = stream.UsesRaw ? Common.DeserializeObject(stream.Read(0) as byte[]) as BaseNodeTag : stream.Read(0) as BaseNodeTag; // We find the link. ManagedNode baseCached = common.Manager.Find(tag.Link) as ManagedNode; // Avoid processing once more. if (baseCached == null) { // We do not reset it because it can be mounted in future. throw new NodeNotFoundException("The base node " + tag.ToString() + " could not be found."); } // Must also take version into account. if (tag.Version != ulong.MaxValue) { baseCached = baseCached[tag.Version] as ManagedNode; if (baseCached == null) { throw new NodeNotFoundException("The base node " + tag.ToString() + " could not be found."); } } return(baseCached); } }