Ejemplo n.º 1
0
        static void Add(Service service)
        {
            services.Add(service);
            foreach (Translator translator in service.Translators)
            {
                AddServiceItem(translator);
                translators.Add(translator);
                foreach (LanguagePair langPair in translator.SupportedTranslations)
                {
                    TranslatorsCollection translators_list;
                    if (!langpair_translators.TryGetValue(langPair, out translators_list))
                    {
                        translators_list = new TranslatorsCollection();
                        langpair_translators.Add(langPair, translators_list);
                    }
                    translators_list.Add(translator);

                    AddLangPairServiceItem(langPair, translator);
                }
            }

            foreach (BilingualDictionary dictionary in service.BilingualDictionaries)
            {
                AddServiceItem(dictionary);
                bilingualDictionaries.Add(dictionary);
                foreach (LanguagePair langPair in dictionary.SupportedTranslations)
                {
                    BilingualDictionariesCollection dictionaries_list;
                    if (!langpair_bilingualDictionaries.TryGetValue(langPair, out dictionaries_list))
                    {
                        dictionaries_list = new BilingualDictionariesCollection();
                        langpair_bilingualDictionaries.Add(langPair, dictionaries_list);
                    }

                    dictionaries_list.Add(dictionary);

                    AddLangPairServiceItem(langPair, dictionary);
                }
            }

            foreach (MonolingualDictionary dictionary in service.MonolingualDictionaries)
            {
                AddServiceItem(dictionary);
                monolingualDictionaries.Add(dictionary);
                foreach (LanguagePair langPair in dictionary.SupportedTranslations)
                {
                    MonolingualDictionariesCollection dictionaries_list;
                    if (!langpair_monolingualDictionaries.TryGetValue(langPair, out dictionaries_list))
                    {
                        dictionaries_list = new MonolingualDictionariesCollection();
                        langpair_monolingualDictionaries.Add(langPair, dictionaries_list);
                    }

                    dictionaries_list.Add(dictionary);

                    AddLangPairServiceItem(langPair, dictionary);
                }
            }
        }
Ejemplo n.º 2
0
        protected void AddTranslator(Translator translator)
        {
            if (translator == null)
            {
                throw new ArgumentNullException("translator");
            }

            translator.Service = this;
            translators.Add(translator);
        }