/// <summary>
        /// Instantiates the variables and fills the list file content into
        /// a Dictionary collection object.
        /// </summary>
        /// <param name="provider"></param>
        /// <param name="languages"></param>
        #region "ListTranslationProviderLanguageDirection"
        public ListTranslationProviderLanguageDirection(ListTranslationProvider provider, LanguagePair languages)
        {
            #region "Instantiate"
            _provider           = provider;
            _languageDirection  = languages;
            _options            = _provider.Options;
            _visitor            = new ListTranslationProviderElementVisitor(_options);
            _listOfTranslations = new Dictionary <string, string>();
            #endregion

            #region "CompileCollection"
            // Load the content of the specified list file and fill it
            // into the multiple identical sources are not allowed
            using (StreamReader sourceFile = new StreamReader(_options.ListFileName))
            {
                sourceFile.ReadLine(); // Skip the first line as it contains the language direction.

                char fileDelimiter = Convert.ToChar(_options.Delimiter);
                while (!sourceFile.EndOfStream)
                {
                    string[] currentPair = sourceFile.ReadLine().Split(fileDelimiter);
                    if (currentPair.Count <string>() != 2)
                    {
                        // The current line does not contain a proper source/target segment pair.
                        continue;
                    }

                    // Add the source/target segment pair to the collection
                    // after checking that the current source segment does not
                    // already exist in the Dictionary.
                    if (!_listOfTranslations.ContainsKey(currentPair[0]))
                    {
                        _listOfTranslations.Add(currentPair[0], currentPair[1]);
                    }
                }
                sourceFile.Close();
            }
            #endregion
        }
 public ListTranslationProvider(ListTranslationOptions options)
 {
     Options = options;
 }
示例#3
0
 public ListTranslationProviderElementVisitor(ListTranslationOptions options)
 {
     _options = options;
 }
 public ListProviderConfDialog(ListTranslationOptions options)
 {
     Options = options;
     InitializeComponent();
     UpdateDialog();
 }