Exemple #1
0
 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);
        }
Exemple #3
0
        internal PM.Bibliography PostProcessBibliography(DE.Style style, PM.Bibliography bibliography)
        {
            if (bibliography != null)
            {
                _overridesBibliography.ForEach(x => bibliography = x.PostProcess(style, bibliography));
            }

            return(bibliography);
        }
Exemple #4
0
        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);
        }
Exemple #6
0
        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);
            }
        }
Exemple #9
0
 public DM.Citation CreateCitationGraphic(DE.Style style, DE.Format format, DM.Graphic graphic)
 {
     return(CreateCitationAsync(style, format, graphic).Result);
 }
Exemple #10
0
 public DM.Citation CreateCitationWebpage(DE.Style style, DE.Format format, DM.Webpage webpage)
 {
     return(CreateCitationAsync(style, format, webpage).Result);
 }
Exemple #11
0
 public DM.Citation CreateCitationMagazine(DE.Style style, DE.Format format, DM.Magazine magazine)
 {
     return(CreateCitationAsync(style, format, magazine).Result);
 }
Exemple #12
0
 public DM.Citation CreateCitationChapter(DE.Style style, DE.Format format, DM.Chapter chapter)
 {
     return(CreateCitationAsync(style, format, chapter).Result);
 }
Exemple #13
0
 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);
 }
Exemple #16
0
 public DM.Citation CreateCitationLegislation(DE.Style style, DE.Format format, DM.Legislation legislation)
 {
     return(CreateCitationAsync(style, format, legislation).Result);
 }
Exemple #17
0
 public DM.Citation CreateCitationLegalCase(DE.Style style, DE.Format format, DM.LegalCase legalCase)
 {
     return(CreateCitationAsync(style, format, legalCase).Result);
 }
Exemple #18
0
 public DM.Citation CreateCitationVideoRecording(DE.Style style, DE.Format format, DM.VideoRecording videoRecording)
 {
     return(CreateCitationAsync(style, format, videoRecording).Result);
 }
Exemple #19
0
 public DM.Citation CreateCitationConferencePaper(DE.Style style, DE.Format format, DM.ConferencePaper conferencePaper)
 {
     return(CreateCitationAsync(style, format, conferencePaper).Result);
 }
Exemple #20
0
 public DM.Citation CreateCitationBroadcast(DE.Style style, DE.Format format, DM.Broadcast broadcast)
 {
     return(CreateCitationAsync(style, format, broadcast).Result);
 }
Exemple #21
0
 public DM.Citation CreateCitationBook(DE.Style style, DE.Format format, DM.Book book)
 {
     return(CreateCitationAsync(style, format, book).Result);
 }
Exemple #22
0
 public DM.Citation CreateCitationPersonalCommunication(DE.Style style, DE.Format format, DM.PersonalCommunication personalCommunication)
 {
     return(CreateCitationAsync(style, format, personalCommunication).Result);
 }
Exemple #23
0
 public DM.Citation CreateCitationJournal(DE.Style style, DE.Format format, DM.Journal journal)
 {
     return(CreateCitationAsync(style, format, journal).Result);
 }
Exemple #24
0
 public DM.Citation CreateCitationInterview(DE.Style style, DE.Format format, DM.Interview interview)
 {
     return(CreateCitationAsync(style, format, interview).Result);
 }
Exemple #25
0
 public DM.Citation CreateCitationNewspaper(DE.Style style, DE.Format format, DM.Newspaper newspaper)
 {
     return(CreateCitationAsync(style, format, newspaper).Result);
 }
Exemple #26
0
 public DM.Citation CreateCitationPresentation(DE.Style style, DE.Format format, DM.Presentation presentation)
 {
     return(CreateCitationAsync(style, format, presentation).Result);
 }
Exemple #27
0
 public DM.Citation CreateCitationEncyclopedia(DE.Style style, DE.Format format, DM.Encyclopedia encyclopedia)
 {
     return(CreateCitationAsync(style, format, encyclopedia).Result);
 }
Exemple #28
0
 public DM.Citation CreateCitationMap(DE.Style style, DE.Format format, DM.Map map)
 {
     return(CreateCitationAsync(style, format, map).Result);
 }
Exemple #29
0
 public DM.Citation CreateCitationAudioRecording(DE.Style style, DE.Format format, DM.AudioRecording audioRecording)
 {
     return(CreateCitationAsync(style, format, audioRecording).Result);
 }
Exemple #30
0
 public DM.Citation CreateCitationBill(DE.Style style, DE.Format format, DM.Bill bill)
 {
     return(CreateCitationAsync(style, format, bill).Result);
 }