iwantedue.OutlookStorage.Message.LoadStorage C# (CSharp) Method

LoadStorage() protected method

Processes sub storages on the specified storage to capture attachment and recipient data.
protected LoadStorage ( NativeMethods storage ) : void
storage NativeMethods The storage to check for attachment and recipient data.
return void
            protected override void LoadStorage(NativeMethods.IStorage storage)
            {
                base.LoadStorage(storage);

                foreach (ComTypes.STATSTG storageStat in this.subStorageStatistics.Values)
                {
                    //element is a storage. get it and add its statistics object to the sub storage dictionary
                    NativeMethods.IStorage subStorage = this.storage.OpenStorage(storageStat.pwcsName, IntPtr.Zero, NativeMethods.STGM.READ | NativeMethods.STGM.SHARE_EXCLUSIVE, IntPtr.Zero, 0);

                    //run specific load method depending on sub storage name prefix
                    if (storageStat.pwcsName.StartsWith(OutlookStorage.RECIP_STORAGE_PREFIX))
                    {
                        Recipient recipient = new Recipient(new OutlookStorage(subStorage));
                        this.recipients.Add(recipient);
                    }
                    else if (storageStat.pwcsName.StartsWith(OutlookStorage.ATTACH_STORAGE_PREFIX))
                    {
                        this.LoadAttachmentStorage(subStorage);
                    }
                    else
                    {
                        //release sub storage
                        Marshal.ReleaseComObject(subStorage);
                    }
                }
            }