private void FlushIndexTable() { if (cachedTable == null) { return; } using (IDriverTypedStream stream = node.GetTypedStream(OpenMode.Write, typeof(IndexTableTag).FullName)) { IndexTableTag tag = new IndexTableTag(cachedTable); stream.Write(0, typeof(IndexTableTag).FullName, stream.UsesRaw ? (object)Common.SerializeToArray(tag) : tag); } }
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> /// Helper; creates cached TS. /// </summary> private ManagedTypedStream GetCachedTypedStream(string t, OpenMode mode) { // First update all unused typed streams containers. typedStreams.RemoveAll(delegate(TypedStreamContainer c) { if (!c.IsAlive) { return(true); } return(false); }); // Foreach stream. foreach (TypedStreamContainer c in typedStreams) { if (c.Type == t) { ManagedTypedStream stream = c.Create(mode); if (stream != null) { return(stream); } break; } } // We have to create it. // We ask node to provide TS. IDriverTypedStream s = node.GetTypedStream(OpenMode.ReadWrite, t); if (s == null) { return(null); } TypedStreamContainer cont = new TypedStreamContainer(t, s); // We add it in front, to make sure we first check this new type. typedStreams.Insert(0, cont); return(cont.Create(mode)); }
/// <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); } }
/// <summary> /// Constructor. /// </summary> /// <param name="inner">The internal typed stream.</param> public TypedStreamContainer(string t, IDriverTypedStream inner) { type = t; internalTS = inner; }
bool ITransparent.IsTransparent(IDriverTypedStream typedStream) { return(typedStream is LdapTypedStream); }