private static List <Citation> ReadFromDisk(PDFDocument pdf_document)
        {
            WPFDoEvents.AssertThisCodeIs_NOT_RunningInTheUIThread();

            List <Citation> citations = new List <Citation>();

            List <LibraryDB.LibraryItem> library_items = pdf_document.Library.LibraryDB.GetLibraryItems(pdf_document.Fingerprint, PDFDocumentFileLocations.CITATIONS);

            if (0 < library_items.Count)
            {
                LibraryDB.LibraryItem library_item = library_items[0];

                string      lines_all = Encoding.UTF8.GetString(library_item.data);
                StringArray lines     = StringTools.splitAtNewline(lines_all);
                foreach (string line in lines)
                {
                    string[] chunks = line.Split(',');

                    Citation citation = new Citation();
                    citation.fingerprint_outbound = chunks[0];
                    citation.fingerprint_inbound  = chunks[1];
                    citation.type = (Citation.Type)Convert.ToInt32(chunks[2]);

                    citations.Add(citation);
                }
            }

            return(citations);
        }
        private void AddCitation(Citation new_citation)
        {
            // Utilities.LockPerfTimer l1_clk = Utilities.LockPerfChecker.Start();
            lock (citations_lock)
            {
                // l1_clk.LockPerfTimerStop();
                // We can't cite ourself!
                if (0 == new_citation.fingerprint_outbound.CompareTo(new_citation.fingerprint_inbound))
                {
                    return;
                }

                // Try to update an existing record
                bool            needs_write     = false;
                bool            citation_exists = false;
                List <Citation> citations       = Citations_RAW;
                foreach (Citation citation in citations)
                {
                    if (new_citation.Equals(citation))
                    {
                        citation_exists = true;
                        break;
                    }
                }

                // If there was no existing record
                if (!citation_exists)
                {
                    citations.Add(new_citation);
                    needs_write = true;
                }

                // If we need to write, write!
                if (needs_write)
                {
                    WriteToDisk(pdf_document, citations);
                }
            }
        }
        private void AddCitation(Citation new_citation)
        {
            lock (this)
            {
                // We can't cite ourself!
                if (0 == new_citation.fingerprint_outbound.CompareTo(new_citation.fingerprint_inbound))
                {
                    return;
                }

                // Try to update an existing record
                bool            needs_write     = false;
                bool            citation_exists = false;
                List <Citation> citations       = Citations;
                foreach (Citation citation in citations)
                {
                    if (new_citation.Equals(citation))
                    {
                        citation_exists = true;
                        break;
                    }
                }

                // If there was no existing record
                if (!citation_exists)
                {
                    citations.Add(new_citation);
                    needs_write = true;
                }

                // If we need to write, write!
                if (needs_write)
                {
                    WriteToDisk(pdf_document, citations);
                }
            }
        }