Example #1
0
        void LoadStreamTable()
        {
            StorageStreamMetadata streamMetadata;

            stream.Position = 0;
            int index = 0;

            map.Clear();

            items.Clear();

            int cnt = (int)stream.Length / StorageStreamMetadata.StructureSize;

            for (int i = 0; i < cnt; i++)
            {
                streamMetadata = StorageStreamMetadata.Load(stream, i);

                if (streamMetadata.StreamId != Guid.Empty)
                {
                    map.Set(index, true);
                    items.Add(streamMetadata.StreamId, index);
                }

                index++;
            }
        }
Example #2
0
        /// <summary>
        /// Returns table entries
        /// </summary>
        public IEnumerable <StorageStreamMetadata> Get()
        {
            StorageStreamMetadata streamMetadata;

            foreach (StorageStreamMetadata entry in entriesAddedInTransaction.Values)
            {
                yield return(entry);
            }
            for (int i = 0; i < stream.Length / StorageStreamMetadata.StructureSize; i++)
            {
                streamMetadata = StorageStreamMetadata.Load(stream, i);
                if (streamMetadata.StreamId != Guid.Empty)
                {
                    yield return(streamMetadata);
                }
            }
        }
Example #3
0
        /// <summary>
        /// Gets first segment location for specified streamId or nulll if not found.
        /// </summary>
        public StorageStreamMetadata Get(Guid streamId)
        {
            StorageStreamMetadata result = null;

            int index;

            // Search through entries in memory
            if (!entriesAddedInTransaction.TryGetValue(streamId, out result))
            {
                // Load it from stream table stream
                if (items.TryGetValue(streamId, out index))
                {
                    result = StorageStreamMetadata.Load(stream, index);
                }
            }

            return(result);
        }