internal List <PM.ContentItem> PreProcessCitation(DE.Style style, List <PM.ContentItem> contentItems) { if (contentItems != null) { List <PM.ContentItem> results = new List <PM.ContentItem>(); foreach (PM.ContentItem contentItem in contentItems) { if (contentItem != null) { PM.ContentItem result = contentItem; _overridesCitation.ForEach(x => result = x.PreProcess(style, result)); results.Add(result); } else { results.Add(contentItem); } } return(results); } else { return(contentItems); } }
public PM.ContentItem PreProcess(DE.Style style, PM.ContentItem contentItem) { switch (style) { case DE.Style.Unknown: // Do Nothing break; case DE.Style.MLA7: case DE.Style.MLA8: contentItem = PreProcessMLA(contentItem); break; case DE.Style.APA5: case DE.Style.APA6: case DE.Style.APA7: contentItem = PreProcessAPA(contentItem); break; case DE.Style.Chicago17: contentItem = PreProcessChicago(contentItem); break; case DE.Style.Harvard10: case DE.Style.ASA6: case DE.Style.Turabian8: // Do Nothing break; default: throw new NotImplementedException(); } return(contentItem); }
internal PM.Bibliography PostProcessBibliography(DE.Style style, PM.Bibliography bibliography) { if (bibliography != null) { _overridesBibliography.ForEach(x => bibliography = x.PostProcess(style, bibliography)); } return(bibliography); }
internal PM.Citation PostProcessCitation(DE.Style style, PM.Citation citation) { if (citation != null) { _overridesCitation.ForEach(x => citation = x.PostProcess(style, citation)); } return(citation); }
public PM.ContentItem PreProcess(DE.Style style, PM.ContentItem contentItem) { if (contentItem != null) { if (!string.IsNullOrEmpty(contentItem.PageNumber) && contentItem.PageNumber.EndsWith("+")) { int hash1 = Math.Abs(Guid.NewGuid().GetHashCode()); int hash2 = Math.Abs(Guid.NewGuid().GetHashCode()); string replacement = string.Concat(Math.Min(hash1, hash2).ToString(), ", ", Math.Max(hash1, hash2).ToString()); _mappings.Add(replacement, contentItem.PageNumber); contentItem.PageNumber = replacement; } } return(contentItem); }
private async Task <DM.Citation> CreateCitationAsync(DE.Style style, DE.Format format, DM.ContentItem contentItem) { ExpandoObject request = new ExpandoObject(); List <PM.ContentItem> requestList = new List <PM.ContentItem>(); requestList.Add(PF.CiteProcFactory.Build("0", contentItem)); requestList = _overrideManager.PreProcessCitation(style, requestList); requestList.ForEach(x => request.TryAdd(x.ID, x)); using (StringAsTempFile file = new StringAsTempFile(GetContents(), CancellationToken.None)) { string result = await NodeServices.InvokeAsync <string>(file.FileName, GetLibrary(), PL.Locale.GetLocale(), PD.Definition.GetDefinition(style), PF.CiteProcFactory.Build(format), JObject.Parse(request.ToSerializedJSON())); PM.Citation citation = JsonConvert.DeserializeObject <PM.Citation>(result); citation.ProcessExceptions(); citation = _overrideManager.PostProcessCitation(style, citation); DM.Citation response = PF.CiteProcFactory.Build(citation); return(response); } }
public PM.Bibliography PostProcess(DE.Style style, PM.Bibliography bibliography) { if (bibliography != null && bibliography.Values != null) { List <string> replacedValues = new List <string>(); foreach (string value in bibliography.Values) { string replacedValue = value; foreach (KeyValuePair <string, string> mapping in _mappings) { if (!string.IsNullOrEmpty(replacedValue) && !string.IsNullOrEmpty(mapping.Key) && !string.IsNullOrEmpty(mapping.Value)) { replacedValue = replacedValue.Replace(mapping.Key, mapping.Value); } } replacedValues.Add(replacedValue); } bibliography.Values = replacedValues; } return(bibliography); }
private async Task <DM.Bibliography> CreateBibliographyAsync(DE.Style style, DE.Format format, List <DM.ContentItem> contentItems) { ExpandoObject request = new ExpandoObject(); List <PM.ContentItem> requestList = new List <PM.ContentItem>(); requestList.AddRange(contentItems.Select((x, i) => PF.CiteProcFactory.Build(i.ToString(), x))); requestList = _overrideManager.PreProcessBibliography(style, requestList); requestList.ForEach(x => request.TryAdd(x.ID, x)); using (StringAsTempFile file = new StringAsTempFile(GetContents(), CancellationToken.None)) { string result = await NodeServices.InvokeAsync <string>(file.FileName, GetLibrary(), PL.Locale.GetLocale(), PD.Definition.GetDefinition(style), PF.CiteProcFactory.Build(format), JObject.Parse(request.ToSerializedJSON())); PM.Bibliography bibliography = JsonConvert.DeserializeObject <PM.Bibliography>(result); bibliography.ProcessExceptions(); bibliography = _overrideManager.PostProcessBibliography(style, bibliography); DM.Bibliography response = PF.CiteProcFactory.Build(bibliography); return(response); } }
public DM.Citation CreateCitationGraphic(DE.Style style, DE.Format format, DM.Graphic graphic) { return(CreateCitationAsync(style, format, graphic).Result); }
public DM.Citation CreateCitationWebpage(DE.Style style, DE.Format format, DM.Webpage webpage) { return(CreateCitationAsync(style, format, webpage).Result); }
public DM.Citation CreateCitationMagazine(DE.Style style, DE.Format format, DM.Magazine magazine) { return(CreateCitationAsync(style, format, magazine).Result); }
public DM.Citation CreateCitationChapter(DE.Style style, DE.Format format, DM.Chapter chapter) { return(CreateCitationAsync(style, format, chapter).Result); }
public DM.Citation CreateCitationReport(DE.Style style, DE.Format format, DM.Report report) { return(CreateCitationAsync(style, format, report).Result); }
public PM.Citation PostProcess(DE.Style style, PM.Citation citation) { return(citation); }
public PM.Bibliography PostProcess(DE.Style style, PM.Bibliography bibliography) { return(bibliography); }
public DM.Citation CreateCitationLegislation(DE.Style style, DE.Format format, DM.Legislation legislation) { return(CreateCitationAsync(style, format, legislation).Result); }
public DM.Citation CreateCitationLegalCase(DE.Style style, DE.Format format, DM.LegalCase legalCase) { return(CreateCitationAsync(style, format, legalCase).Result); }
public DM.Citation CreateCitationVideoRecording(DE.Style style, DE.Format format, DM.VideoRecording videoRecording) { return(CreateCitationAsync(style, format, videoRecording).Result); }
public DM.Citation CreateCitationConferencePaper(DE.Style style, DE.Format format, DM.ConferencePaper conferencePaper) { return(CreateCitationAsync(style, format, conferencePaper).Result); }
public DM.Citation CreateCitationBroadcast(DE.Style style, DE.Format format, DM.Broadcast broadcast) { return(CreateCitationAsync(style, format, broadcast).Result); }
public DM.Citation CreateCitationBook(DE.Style style, DE.Format format, DM.Book book) { return(CreateCitationAsync(style, format, book).Result); }
public DM.Citation CreateCitationPersonalCommunication(DE.Style style, DE.Format format, DM.PersonalCommunication personalCommunication) { return(CreateCitationAsync(style, format, personalCommunication).Result); }
public DM.Citation CreateCitationJournal(DE.Style style, DE.Format format, DM.Journal journal) { return(CreateCitationAsync(style, format, journal).Result); }
public DM.Citation CreateCitationInterview(DE.Style style, DE.Format format, DM.Interview interview) { return(CreateCitationAsync(style, format, interview).Result); }
public DM.Citation CreateCitationNewspaper(DE.Style style, DE.Format format, DM.Newspaper newspaper) { return(CreateCitationAsync(style, format, newspaper).Result); }
public DM.Citation CreateCitationPresentation(DE.Style style, DE.Format format, DM.Presentation presentation) { return(CreateCitationAsync(style, format, presentation).Result); }
public DM.Citation CreateCitationEncyclopedia(DE.Style style, DE.Format format, DM.Encyclopedia encyclopedia) { return(CreateCitationAsync(style, format, encyclopedia).Result); }
public DM.Citation CreateCitationMap(DE.Style style, DE.Format format, DM.Map map) { return(CreateCitationAsync(style, format, map).Result); }
public DM.Citation CreateCitationAudioRecording(DE.Style style, DE.Format format, DM.AudioRecording audioRecording) { return(CreateCitationAsync(style, format, audioRecording).Result); }
public DM.Citation CreateCitationBill(DE.Style style, DE.Format format, DM.Bill bill) { return(CreateCitationAsync(style, format, bill).Result); }