/// <summary> /// Constructor - called when the first instance of the citation is found /// </summary> /// <param name="citation">The citation backing the viewmodel</param> /// <param name="medlineFile">The file containing the citation</param> public CitationViewModel(Citation citation) { if (citation == null) { throw new ArgumentNullException("citation"); } this.citation = citation; }
/// <summary> /// Tries to create a citation if the given fields are valid /// </summary> /// <param name="currentId">Id of the citation</param> /// <param name="currentTitle">Title of the citation</param> /// <param name="currentAbstract">Abstract of the article</param> /// <param name="contentBuilder">The content builder holding the whole file</param> /// <param name="justParsedCitation">The result - the citation</param> /// <returns>True if the citation was created, false otherwise</returns> private static Citation CreateCitation(string currentId, string currentTitle, string currentAbstract, StringBuilder contentBuilder) { Citation citation = null; if (!string.IsNullOrWhiteSpace(currentId)) { if (!string.IsNullOrWhiteSpace(currentTitle)) { if (!string.IsNullOrWhiteSpace(currentAbstract)) { if (contentBuilder != null) { citation = new Citation(currentId, currentTitle, currentAbstract, contentBuilder.ToString()); } else { throw new ArgumentNullException("Content builder is null"); } } else { throw new ArgumentException("Abstract is null or whitespace"); } } else { throw new ArgumentException("Title is null or whitespace"); } } else { throw new ArgumentException("Id is null or whitespace"); } return citation; }