public void AttatchDocument(PDFDocument.DocumentHandle handle) { lo ck(_documentHandles) { _documentHandles.Add(handle); } }
public void DetachDocument(PDFDocument.DocumentHandle handle) { if (handle.IsAlive) { foreach (Selector selector in _forms.Keys) { PDFImportedObjectTable table = _forms[selector]; if (table.ExternalDocument != null && table.ExternalDocument.Handle == handle) { _forms.Remove(selector); break; } } } // Clean table bool itemRemoved = true; while (itemRemoved) { itemRemoved = false; foreach (Selector selector in _forms.Keys) { PDFImportedObjectTable table = _forms[selector]; if (table.ExternalDocument == null) { _forms.Remove(selector); itemRemoved = true; break; } } } }
public void DetatchDocument(PDFDocument.DocumentHandle handle) { lo ck(_documentHandles) { // Notify other documents about detach int count = _documentHandles.Count; for (int idx = 0; idx < count; idx++) { if (((PDFDocument.DocumentHandle)_documentHandles[idx]).IsAlive) { PDFDocument target = ((PDFDocument.DocumentHandle)_documentHandles[idx]).Target; if (target != null) { target.OnExternalDocumentFinalized(handle); } } } // Clean up table for (int idx = 0; idx < _documentHandles.Count; idx++) { PDFDocument target = ((PDFDocument.DocumentHandle)_documentHandles[idx]).Target; if (target == null) { _documentHandles.RemoveAt(idx); idx--; } } } //lo ck (documents) //{ // int index = IndexOf(document); // if (index != -1) // { // documents.RemoveAt(index); // int count = documents.Count; // for (int idx = 0; idx < count; idx++) // { // PDFDocument target = ((WeakReference)documents[idx]).Target as PDFDocument; // if (target != null) // target.OnExternalDocumentFinalized(document); // } // for (int idx = 0; idx < documents.Count; idx++) // { // PDFDocument target = ((WeakReference)documents[idx]).Target as PDFDocument; // if (target == null) // { // documents.RemoveAt(idx); // idx--; // } // } // } //} }