Dim newWord As VocabularyWord

 'Обойти все записи

 While (dataReader.Read)

  Dim thisword_gender As VocabularyWord.WordGender

  Dim thisword_function As VocabularyWord.WordFunction

  thisword_gender = CType(dataReader.GetInt32( _

   DatabaseAccess.DS_WORDS_COLUMNINDEX_GERMANGENDER), _

   VocabularyWord.WordGender)

  thisword_function = CType(dataReader.GetInt32( _

   DatabaseAccess.DS_WORDS_COLUMNINDEX_WORDFUNCTION), _

   VocabularyWord.WordFunction)

  'Поместить данные для только что считанного слова в класс

  newWord = New VocabularyWord(dataReader.GetString( _

   DatabaseAccess.DS_WORDS_COLUMNINDEX_ENGLISHWORD), dataReader.GetString( _

   DatabaseAccess.DS_WORDS_COLUMNINDEX_GERMANWORD), _

   thisword_gender, thisword_function)

  'Добавить новое слово в массив списков

  m_vocabularyWords_All.Add(newWord)

  'Слова могут принадлежать нескольким группам, поэтому

  'необходимо выполнить проверку с использованием операции логического И

  'для проверки того, что слово относится к данной категории

  If ((newWord.getWordFunction And _

   VocabularyWord.WordFunction.Noun) <> 0) Then

   m_vocabularyWords_Nouns.Add(newWord)

  End If

  If ((newWord.getWordFunction And _

   VocabularyWord.WordFunction.Verb) <> 0)

   Then m_vocabularyWords_Verbs.Add(newWord)

  End If

  If ((newWord.getWordFunction And _

   VocabularyWord.WordFunction.Adjective) <> 0) Then

   m_vocabularyWords_Adjectives.Add(newWord)

  End If

  If ((newWord.getWordFunction And _

   VocabularyWord.WordFunction.Adverb) <> 0) Then

   m_vocabularyWords_Adverbs.Add(newWord)

  End If

  If ((newWord.getWordFunction And _

   VocabularyWord.WordFunction.Preposition) <> 0) Then

   m_vocabularyWords_Prepositions.Add(newWord)

  End If

 End While

 'Закрыть объект DataReader

 dataReader.Close

End Sub

End Class

Листинг 14.8. Пример кода управления данными для VocabularyWord.cs

Option Strict On

Imports System

'------------------------------

'Хранит данные слова из словаря

'------------------------------

Friend Class VocabularyWord

_

 Public Enum WordFunction

 Noun = 1

 Verb = 2

 Pronoun = 4

 Adverb = 8

 Adjective = 16

 Preposition = 32

 Phrase = 64

End Enum

Public Enum WordGender

 notApplicable = 0

 Masculine = 1

 Feminine = 2

 Neuter = 3

End Enum

Private m_englishWord As String

Private m_germanWord As String

Private m_germanGender As VocabularyWord.WordGender

Private m_wordFunction As VocabularyWord.WordFunction

Public ReadOnly Property EnglishWord As String

 Get

  Return m_englishWord

 End Get

End Property

Public ReadOnly Property GermanWord As String

 Get

  Return m_germanWord

 End Get

End Property

Public ReadOnly Property getWordFunction As WordFunction

 Get

  Return m_wordFunction

 End Get

End Property

Перейти на страницу:

Похожие книги