private void WriteAndCommit(string filename, Stream outfile, DBPFFile dbfile, Dictionary <DBPFReference, KeyValuePair <DBPFIndexEntry, byte[]> > toreplace, List <KeyValuePair <DBPFIndexEntry, byte[]> > toadd)
        {
            dbfile.Write(outfile, delegate(ref DBPFIndexEntry entry, ref byte[] data)
            {
                KeyValuePair <DBPFIndexEntry, byte[]> replacement;
                if (toreplace.TryGetValue(entry.Reference, out replacement))
                {
                    entry = replacement.Key;
                    data  = replacement.Value;
                }
            }, toadd);

            foreach (DBPFReference commitref in toreplace.Keys)
            {
                StubbleSource source = new StubbleSource();
                source.SourceFile  = filename;
                source.SourceTable = commitref;
                mData.CommitModifiedData((Languages)(commitref.Instance >> 56), source);
            }
            foreach (KeyValuePair <DBPFIndexEntry, byte[]> commitentry in toadd)
            {
                StubbleSource source = new StubbleSource();
                source.SourceFile  = filename;
                source.SourceTable = commitentry.Key.Reference;
                mData.CommitModifiedData((Languages)(commitentry.Key.Reference.Instance >> 56), source);
            }
        }
        private void WriteAndCommit(string filename, Stream outfile, DBPFFile dbfile, Dictionary<DBPFReference, KeyValuePair<DBPFIndexEntry, byte[]>> toreplace, List<KeyValuePair<DBPFIndexEntry, byte[]>> toadd)
        {
            dbfile.Write(outfile, delegate(ref DBPFIndexEntry entry, ref byte[] data)
            {
                KeyValuePair<DBPFIndexEntry, byte[]> replacement;
                if (toreplace.TryGetValue(entry.Reference, out replacement))
                {
                    entry = replacement.Key;
                    data = replacement.Value;
                }
            }, toadd);

            foreach (DBPFReference commitref in toreplace.Keys)
            {
                StubbleSource source = new StubbleSource();
                source.SourceFile = filename;
                source.SourceTable = commitref;
                mData.CommitModifiedData((Languages)(commitref.Instance >> 56), source);
            }
            foreach (KeyValuePair<DBPFIndexEntry, byte[]> commitentry in toadd)
            {
                StubbleSource source = new StubbleSource();
                source.SourceFile = filename;
                source.SourceTable = commitentry.Key.Reference;
                mData.CommitModifiedData((Languages)(commitentry.Key.Reference.Instance >> 56), source);
            }
        }