private void AddKeyWords2Book(TreeViewItem_Attribute attr, Book book) { KeyWord keyWord; if (string.IsNullOrEmpty(attr.AttributeValue) || string.IsNullOrWhiteSpace(attr.AttributeValue)) { return; } string[] words = attr.AttributeValue.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var word in words) { if (string.IsNullOrEmpty(word) || string.IsNullOrWhiteSpace(word)) { continue; } keyWord = new KeyWord() { Word = word }; if (book.KeyWords.Contains(keyWord)) { continue; } book.KeyWords.Add(keyWord); } }
public void GetItem_Attribute_AttributeValue() { string str = "Test:Value"; TreeViewItem_Attribute item = (TreeViewItem_Attribute)TreeItemsFactory.GetItem(str); Assert.AreEqual <string>("Value", item.AttributeValue); }
private void AddAuthor2Book(TreeViewItem_Attribute authorItem, Book book) { bool isAuthor = false; Author author = new Author(); TreeViewItem_Attribute attr; foreach (var info in authorItem.GetChilds_Items()) { attr = info as TreeViewItem_Attribute; if (attr != null) { switch (attr.AttributeType) { case AttributeType.FirstName: author.FirstName = attr.AttributeValue; isAuthor = true; break; case AttributeType.LastName: author.LastName = attr.AttributeValue; isAuthor = true; break; case AttributeType.MiddleName: author.MiddleName = attr.AttributeValue; isAuthor = true; break; case AttributeType.NickName: author.NickName = attr.AttributeValue; isAuthor = true; break; case AttributeType.EMail: author.EMail = attr.AttributeValue; isAuthor = true; break; default: break; } } } if (!isAuthor || book.Authors.Contains(author)) { return; } book.Authors.Add(author); }
private void AddGenreFB2Book(TreeViewItem_Attribute genreItem, Book book) { ItemGenre genre; Genre genre4Book; if (!Enum.TryParse <ItemGenre>(genreItem.AttributeValue, true, out genre)) { if (!Enum.TryParse <ItemGenre>("none", true, out genre)) { return; } } genre4Book = new Genre() { Key = genre, Code = genreItem.AttributeValue }; if (book.Genres.Contains(genre4Book)) { return; } book.Genres.Add(genre4Book); }