AddDocumentToCache(Uri documentUri) { // // Retrieve the requested part from the package // PackagePart documentPart = CurrentXpsManager.GetPart(documentUri); if (documentPart == null) { throw new XpsPackagingException(SR.Get(SRID.ReachPackaging_PartNotFound)); } // // If the part is not a fixed document then throw an exception // if (!documentPart.ValidatedContentType().AreTypeAndSubTypeEqual(XpsS0Markup.FixedDocumentContentType)) { throw new XpsPackagingException(SR.Get(SRID.ReachPackaging_NotAFixedDocument)); } // // Create the reader/writer for the part // IXpsFixedDocumentReader fixedDocument = new XpsFixedDocumentReaderWriter(CurrentXpsManager, null, documentPart, _documentCache.Count + 1); // // Cache the new reader/writer for later // _documentCache.Add(fixedDocument); return(fixedDocument); }
AddFixedDocument( ) { // // Create the part and coresponding writer // PackagePart metroPart = CurrentXpsManager.GenerateUniquePart(XpsS0Markup.FixedDocumentContentType); XpsFixedDocumentReaderWriter fixedDocument = new XpsFixedDocumentReaderWriter(CurrentXpsManager, this, metroPart, _documentsWritten + 1); //Here we used to add the fixed document to _documentCache, but _documentCache is never accessed if this object was created as an IXpsFixedDocumentSequenceWriter. //So instead keep a separate documentsWritten count and forget about the cache when using this method. _documentsWritten++; // // Write out FixedDocument markup // AddDocumentToSequence(fixedDocument.Uri); return(fixedDocument); }