Пример #1
0
            public JSInlineCitation CreateInlineCitation(IEnumerable <EntryAndPagePair> itemSources, object idToUse = null)
            {
                // ****IMPORTANT****
                // This is called from InsertCitationSequence, InsertCitation, EditCitation and CitationInserter.UpdateCitationsFromDatabase
                //
                // It is imperative that calls from the first 3 work on an empty CiteProc otherwise the cache gets used to create
                // the citation items. Other than first-use, this means using the item after CiteProc has seen it and maybe modified it
                // (it appears to change the Date Parts to strings in some cases)
                // The next refresh is then comparing incorrect JSON and will want to update it from the database.
                //
                // (CitationInserter.UpdateCitationsFromDatabase calls here but this is always within a Refresh which means a brand new CiteProc anyway
                // and so multiple resets here are not a problem because the raw cache would be empty anyway)
                //			citeproc.ResetProcessorState();

                var result = new JSInlineCitation(citeProc);

                if (idToUse != null)
                {
                    result.CitationID = idToUse;
                }

                result.Properties.NoteIndex = 0;

                foreach (var itemSource in itemSources)
                {
                    var inlineCitationItem = citeProc.CreateJSInlineCitationItem(itemSource);

                    result.CitationItems.Add(inlineCitationItem);
                }

                // We store this before Citeproc gets hold of it!
                result.FieldCodeJSON = citeProc.ToJSON(result.JSObject).Replace('\n', '\v') + "\r";

                return(result);
            }
Пример #2
0
            JSInlineCitation GetCitation(string fieldCodeText)
            {
                JSInlineCitation result;

                if (!inlineCitationCache.TryGetValue(fieldCodeText, out result))
                {
                    //TODO: Move this to common routine
                    var indexOfOpeningBrace = fieldCodeText.IndexOf('{');
                    var citationJSON        = fieldCodeText.Substring(indexOfOpeningBrace);

                    result = JSInlineCitation.FromJSON(citeProc, citationJSON);

                    SetCitation(fieldCodeText, result);
                }

                return(result);
            }
Пример #3
0
        public void NewInlineCitation()
        {
            var citeproc = new CiteProcRunner(HavardCslStyle, () => DocearDatabase);

            var citation = new JSInlineCitation(citeproc);

            Console.WriteLine(citeproc.ToJSON(citation));

            Assert.NotNull(citation.CitationItems);
            Assert.NotNull(citation.Properties);
            Console.WriteLine(citeproc.ToJSON(citation));

            var citationItem = citation.CitationItems.AddNew();

            Console.WriteLine(citeproc.ToJSON(citation));

            citationItem.ID     = "123";
            citationItem.Prefix = "bollox";
            Console.WriteLine(citeproc.ToJSON(citation));
        }
Пример #4
0
 void SetCitation(string fieldCodeText, JSInlineCitation citation)
 {
     inlineCitationCache[fieldCodeText] = citation;
 }