public void CopyAuthorsAndSources(SIDocument newDocument, InfoOwner infoOwner) { var length = infoOwner.Info.Authors.Count; for (int i = 0; i < length; i++) { var authorID = infoOwner.Info.Authors[i].ExtractLink(); if (authorID.Length > 0) { if (newDocument.Authors.All(author => author.Id != authorID)) { var newAuthor = Authors.FirstOrDefault(author => author.Id == authorID); if (newAuthor != null) { newDocument.Authors.Add(newAuthor.Clone()); } } } } length = infoOwner.Info.Sources.Count; for (int i = 0; i < length; i++) { var sourceID = infoOwner.Info.Sources[i].ExtractLink(true); if (sourceID.Length > 0) { if (newDocument.Sources.All(source => source.Id != sourceID)) { var newSource = Sources.FirstOrDefault(source => source.Id == sourceID); if (newSource != null) { newDocument.Sources.Add(newSource.Clone()); } } } } }
/// <summary> /// Получить ссылку на автора из хранилища /// </summary> /// <param name="authors">Список авторов</param> /// <param name="index">Индекс в списке авторов</param> /// <returns>Автор из хранилища</returns> public AuthorInfo GetLink(Authors authors, int index, out string tail) { var link = authors[index].ExtractLink(out tail); return(_authors.FirstOrDefault(author => author.Id == link)); }