// Called when an item has been added to this._ModuleStreams
        private void ModuleStreamAdded(string streamName, ModuleStream moduleStream)
        {
            if (this.DirStream == null)
            {
                throw new NullReferenceException("DirStream was null");
            }

            ++this.DirStream.ModulesRecord.Count;
        }
        public void Add(MODULE module, string SourceCode)
        {
            string moduleName = module.NameRecord.GetModuleNameAsString();
            string streamName = moduleName;

            if (this._ModuleStreams.ContainsKey(streamName))
            {
                throw new ArgumentException(String.Format("Already contains a module stream named {0}", streamName), "moduleStream");
            }

            var stream = new ModuleStream(this.DirStream.InformationRecord, module, SourceCode);

            throw new NotImplementedException();

            /*
             * this._ModuleStreams.Add(streamName, moduleStream);
             * ModuleStreamAdded(streamName, moduleStream);*/
        }
        public VbaStorage(CompoundFile VbaBinFile)
        {
            this.m_disposable = VbaBinFile;

            // _VBA_PROJECT stream
            var VBAStorage = VbaBinFile.RootStorage.GetStorage("VBA");

            this._VBA_PROJECTStream = ReadVbaProjectStream(VBAStorage);

            // DIR STREAM -------------------------
            CFStream thisWorkbookStream = VBAStorage.GetStream("dir");

            Byte[] compressedData = thisWorkbookStream.GetData();
            Byte[] uncompressed   = XlCompressionAlgorithm.Decompress(compressedData);

            var uncompressedDataReader = new XlBinaryReader(ref uncompressed);

            this.DirStream = new DirStream(uncompressedDataReader);

            // MODULE STREAMS ----------------------------------------
            this._ModuleStreams = new Dictionary <string, ModuleStream>(DirStream.ModulesRecord.Modules.Length);
            this.ModuleStreams  = new ReadOnlyDictionary <string, ModuleStream>(this._ModuleStreams);

            foreach (var module in DirStream.ModulesRecord.Modules)
            {
                var streamName  = module.StreamNameRecord.GetStreamNameAsString();
                var stream      = VBAStorage.GetStream(streamName).GetData();
                var localreader = new XlBinaryReader(ref stream);

                var moduleStream = new ModuleStream(DirStream.InformationRecord, module, localreader);

                this._ModuleStreams.Add(streamName, moduleStream);
            }

            // PROJECT stream
            CFStream ProjectStorage = VbaBinFile.RootStorage.GetStream("PROJECT");

            this.ProjectStream = ReadProjectStream(ProjectStorage, this.DirStream.InformationRecord.CodePageRecord);
        }