Example #1
0
            internal void Split(CreateBlock createBlock)
            {
                int num = 2;

                ManifestBlock[] subBlocks = new ManifestBlock[num];
                for (int j = 0; j < num; j++)
                {
                    subBlocks[j] = createBlock();
                }

                List <ManifestRecord> list = new List <ManifestRecord>();
                Converter <ManifestRecord, ManifestRecord> converter = null;

                for (int i = 0; i < num; i++)
                {
                    int index = (int)(i / (double)num * recordList.Count);
                    int num4  = (int)((i + 1.0) / num * recordList.Count);
                    if (converter == null)
                    {
                        converter = mr => mr.ReplaceBlock(subBlocks[i]);
                    }

                    subBlocks[i].recordList = recordList.GetRange(index, num4 - index)
                                              .ConvertAll(converter);
                    ManifestRecord item = recordList[index].ReplaceIndirect(subBlocks[i].blockId);
                    list.Add(item);
                    subBlocks[i].SetDirty();
                }

                recordList = list;
                SetDirty();
            }
Example #2
0
        private Manifest.ManifestRecord Search(Manifest.StopHere stopHere)
        {
            ManifestBlock  rootBlock  = this.rootBlock;
            ManifestRecord tailRecord = ManifestRecord.TailRecord;

            while (true)
            {
                ManifestRecord record2 = null;
                bool           flag    = false;
                foreach (ManifestRecord record3 in new List <ManifestRecord>(rootBlock)
                {
                    tailRecord
                })
                {
                    if (stopHere(record3.path))
                    {
                        if ((record2 == null) || (record2.indirectManifestBlockId < 0))
                        {
                            return(record3);
                        }
                        rootBlock  = this.FetchBlock(record2.indirectManifestBlockId);
                        tailRecord = record3;
                        flag       = true;
                        break;
                    }
                    record2 = record3;
                }
                if (!flag)
                {
                    D.Assert(false, "Should have stopped inside loop.");
                }
            }
        }
Example #3
0
 internal ManifestRecord ReplaceBlock(ManifestBlock manifestBlock)
 {
     return(new ManifestRecord(manifestBlock,
                               path,
                               fileExists,
                               fileLength,
                               indirectManifestBlockId));
 }
Example #4
0
 public ManifestRecord(ManifestBlock block, string path, bool fileExists, long fileLength,
                       int indirectManifestBlockId)
 {
     this.block  = block;
     this.path   = path;
     _fileExists = fileExists;
     _fileLength = fileLength;
     this.indirectManifestBlockId = indirectManifestBlockId;
     D.Assert(block == null || path != null);
 }
Example #5
0
        private ManifestBlock CreateBlock()
        {
            ManifestBlock manifestBlock = new ManifestBlock(new TellManifestDirty(SetDirty),
                                                            storageMethod,
                                                            rootBlock.superBlock.nextUnassignedBlockId);

            rootBlock.superBlock.nextUnassignedBlockId++;
            D.Assert(!blockCache.ContainsKey(manifestBlock.blockId));
            blockCache[manifestBlock.blockId] = manifestBlock;
            return(manifestBlock);
        }
Example #6
0
            public ManifestRecord(MashupParseContext context, ManifestBlock block)
            {
                this.block = block;
                XMLTagReader xMLTagReader = context.NewTagReader("ManifestRecord");

                path                    = context.GetRequiredAttribute("Path");
                _fileExists             = context.GetRequiredAttributeBoolean("FileExists");
                _fileLength             = context.GetRequiredAttributeLong("FileLength");
                indirectManifestBlockId = context.GetRequiredAttributeInt("IndirectManifestBlockId");
                xMLTagReader.SkipAllSubTags();
            }
Example #7
0
        private ManifestBlock FetchBlock(int blockId)
        {
            if (blockCache.ContainsKey(blockId))
            {
                return(blockCache[blockId]);
            }

            ManifestBlock manifestBlock =
                new ManifestBlock(new TellManifestDirty(SetDirty), storageMethod, blockId);

            blockCache[blockId] = manifestBlock;
            return(manifestBlock);
        }
Example #8
0
        internal void Add(string path, long fileLength)
        {
            ManifestRecord manifestRecord = FindFirstGreaterEqual(path);

            if (manifestRecord.path == path)
            {
                manifestRecord.fileExists = true;
                manifestRecord.fileLength = fileLength;
                return;
            }

            ManifestBlock  manifestBlock = manifestRecord.block == null ? rootBlock : manifestRecord.block;
            ManifestRecord newRecord     = new ManifestRecord(manifestBlock, path, true, fileLength, -1);

            manifestBlock.Insert(newRecord, manifestRecord);
            if (manifestBlock.Count > rootBlock.superBlock.splitThreshold)
            {
                manifestBlock.Split(new ManifestBlock.CreateBlock(CreateBlock));
            }
        }
Example #9
0
 public Manifest(RenderOutputMethod storageMethod)
 {
     this.storageMethod = storageMethod;
     rootBlock          = FetchBlock(0);
 }