1    	using System.Collections.Generic;
2    	using System.Globalization;
3    	using System.IO;
4    	using Microsoft.Build.Framework;
5    	using Microsoft.Build.Utilities;
6    	
7    	namespace Intel.Tools.MSBuildTasks.Localize
8    	{
9    		internal class SupportedLanguage
10   		{
11   			public SupportedLanguage(string pcjFile)
12   			{
13   				this.PCJFile = pcjFile;
(1) Event returned_null: "GetParent" returns "null" (checked 1 out of 4 times).
(3) Event null_method_call: Calling a method on null object "System.IO.Directory.GetParent(pcjFile)".
Also see events: [example_checked]
14   				this.Culture = new CultureInfo(Directory.GetParent(pcjFile).Name);
15   				this.LanguageCode = this.Culture.Name;
16   	
17   				this.LicenseFile = string.Format(
18   					@"Setup Files\Compressed Files\{0}\OS Independent",
19   					LicenseFileMap[this.Culture.Name]);
20   			}
21   	
22   			#region Fields
23   			private static Dictionary<string, string> _LicenseFileMap;
24   			#endregion
25   	
26   			#region Properties
27   			public string PCJFile { get; set; }
28   			public CultureInfo Culture { get; private set; }
29   			public string LanguageCode { get; private set; }
30   			/// <summary>
31   			/// Gets or sets the path to the license file associated
32   			/// with this language, relative to the root license folder.
33   			/// </summary>
34   			/// <example>
35   			/// If this instance of SSS represents jp-JP, then this value would be:
36   			/// "Setup Files\Compressed Files\0011-Japanese\OS Independent\License.txt"
37   			/// </example>
38   			public string LicenseFile { get; private set; }
39   			/// <summary>
40   			/// Gets or sets the the file path to the resource file
41   			/// that is the result of running GenLRC on this language.
42   			/// </summary>
43   			public string OutputFile { get; set; }
44   	
45   			public static Dictionary<string, string> LicenseFileMap
46   			{
47   				get
48   				{
49   					if (_LicenseFileMap == null)
50   					{
51   						_LicenseFileMap = new Dictionary<string, string>
52   						{
53   							{ "ar-SA", "Arabic (Saudi Arabia)" },
54   							{ "cs-CZ", "0005-Czech" },
55   							{ "da-DK", "0006-Danish" },
56   							{ "de-DE", "0007-German" },
57   							{ "el-GR", "0008-Greek" },
58   							//{ "en-US", "0009-English" },
59   							{ "es-ES", "000a-Spanish" },
60   							{ "fi-FI", "000b-Finnish" },
61   							{ "fr-FR", "040c-French (Standard)" },
62   							{ "he-IL", "Hebrew" },
63   							{ "hr-HR", "041a-Croatian" },
64   							{ "hu-HU", "000e-Hungarian" },
65   							{ "it-IT", "0010-Italian" },
66   							{ "ja-JP", "0011-Japanese" },
67   							{ "ko-KR", "0012-Korean" },
68   							{ "nb-NO", "0014-Norwegian" },
69   							{ "nl-NL", "0013-Dutch" },
70   							{ "pl-PL", "0015-Polish" },
71   							{ "pt-BR", "0416-Portuguese (Brazilian)" },
72   							{ "pt-PT", "0816-Portuguese (Standard)" },
73   							{ "ro-RO", "0418-Romanian" },
74   							{ "ru-RU", "0019-Russian" },
75   							{ "sk-SK", "Slovak" },
76   							{ "sl-SI", "Slovenian" },
77   							{ "sv-SE", "001d-Swedish" },
78   							{ "th-TH", "001e-Thai" },
79   							{ "tr-TR", "001f-Turkish" },
80   							{ "zh-CN", "0804-Chinese (PRC)" },
81   							{ "zh-TW", "0404-Chinese (Taiwan)" }
82   						};
83   					}
84   					return _LicenseFileMap;
85   				}
86   			}
87   			#endregion
88   	
89   			internal ITaskItem ToITaskItem()
90   			{
91   				var metadata = new Dictionary<string, string>();
92   				metadata.Add("LanguageCode", this.Culture.Name);
93   				metadata.Add("PCJFile", this.PCJFile);
94   				metadata.Add("LicenseFile", this.LicenseFile);
95   	
96   				return new TaskItem(this.OutputFile, metadata);
97   			}
98   		}
99   	}
100