Example #1
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Language"/> class.
		/// </summary>
		/// <param name="languageDto">
		/// The data transfer object with language data.
		/// </param>
		/// <param name="displayNameProvider">
		/// A language name translation provider.
		/// </param>
		/// <param name="flat">Indicates that no children should be created.</param>
		internal Language(
			LanguageDto languageDto,
			LanguageDisplayNameProvider displayNameProvider,
			bool flat)
		{
			_displayNameProvider = displayNameProvider;

			Lcid = languageDto.Lcid;
			SystemLcid = languageDto.SystemLcid;
			IsNeutral = languageDto.IsNeutral;
			IsToolsCatalogSpecific = languageDto.IsToolsCatalogSpecific;
			IsSimplified = languageDto.IsSimplified;
			IsUncorrected = languageDto.IsUncorrected;
			Name = languageDto.Name;
			DefaultCodePage = languageDto.DefaultCodePage;
			Abbreviation = languageDto.Abbreviation;

			var children = new List<Language>();

			if (!flat)
			{
				foreach (LanguageDto child in languageDto.Children)
				{
					var childLanguage = new Language(child, displayNameProvider, false) { Parent = this };
					children.Add(childLanguage);
				}
			}

			Children = new LanguageCollection(children);
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="LanguagesProvider"/> class.
		/// </summary>
		public LanguagesProvider()
		{
			_namesProvider = new LanguageDisplayNameProvider();

			//using (Stream languagesStream = typeof(LanguagesProvider).Assembly.GetManifestResourceStream(
			//	typeof(LanguagesProvider),
			//	"Languages.json"))
			//{
			//	if (languagesStream == null)
			//	{
			//		throw new FileNotFoundException("Cannot find languages resource.");
			//	}

			//	using (var sr = new StreamReader(languagesStream))
			//	using (var jsonTextReader = new JsonTextReader(sr))
			//	{
			//		_languageDtos = new JsonSerializer()
			//			.Deserialize<LanguageDto[]>(jsonTextReader);
			//	}
			//}
			throw new NotImplementedException();

			_hierarchicalLanguages = new Lazy<LanguageCollection>(BuildHierarchicalLanguages);
			_flatLanguages = new Lazy<LanguageCollection>(BuildFlatLanguages);
		}