示例#1
0
		public static string[] GetnamespacestoLocalize()
		{
			var namespacestoLocalize = new List<string>();
			var pathwayDirectory = PathwayPath.GetPathwayDir();
			if (pathwayDirectory == null || !Directory.Exists(pathwayDirectory))
				return new[] { "SIL.PublishingSolution" };
			foreach (var file in Directory.GetFiles(pathwayDirectory, "*.*").Where(f => Regex.IsMatch(f, @"^.+\.(dll|exe)$"))
				)
			{
				var fileInfo = new FileInfo(file);
				if ((fileInfo.Name == "PsTool.dll") || (fileInfo.Name.Contains("Convert")) ||
					(fileInfo.Name.Contains("Writer")) || (fileInfo.Name.Contains("Validator")))
				{
					using (var epubinstalleddirectory = File.OpenRead(Common.FromRegistry(fileInfo.FullName)))
					{

						var sAssembly = Assembly.LoadFrom(epubinstalleddirectory.Name);

						foreach (
							var stype in
								sAssembly.GetTypes()
									.Where(type => type.GetConstructors().Any(s => s.GetParameters().Length == 0)))
						{
							if (!namespacestoLocalize.Contains(stype.Namespace))
								namespacestoLocalize.Add(stype.Namespace);
						}

					}

				}
			}
			return namespacestoLocalize.Distinct().ToArray();
		}