Exemplo n.º 1
0
		ProjectFile TryCreateSatelliteFile(ModuleDef module, string rsrcName, FilenameCreator filenameCreator, ProjectFile nonSatFile) {
			if (!Options.CreateResX)
				return null;
			var asm = module.Assembly;
			Debug.Assert(asm != null && !UTF8String.IsNullOrEmpty(asm.Culture));
			if (asm == null || UTF8String.IsNullOrEmpty(asm.Culture))
				return null;
			var name = FileUtils.RemoveExtension(rsrcName);
			var ext = FileUtils.GetExtension(rsrcName);
			var locName = name + "." + asm.Culture + ext;
			var er = module.Resources.OfType<EmbeddedResource>().FirstOrDefault(a => StringComparer.Ordinal.Equals(a.Name, locName));
			var set = TryCreateResourceElementSet(module, er);
			if (set == null)
				return null;

			var dir = Path.GetDirectoryName(nonSatFile.Filename).Substring(Directory.Length + 1);
			name = Path.GetFileNameWithoutExtension(nonSatFile.Filename);
			ext = Path.GetExtension(nonSatFile.Filename);
			var filename = filenameCreator.CreateFromRelativePath(Path.Combine(dir, name) + "." + asm.Culture, ext);
			return CreateResXFile(module, er, set, filename, string.Empty, true);
		}
Exemplo n.º 2
0
        ProjectFile?TryCreateSatelliteFile(ModuleDef module, string rsrcName, FilenameCreator filenameCreator, ProjectFile nonSatFile)
        {
            if (!Options.CreateResX)
            {
                return(null);
            }
            var asm = module.Assembly;

            Debug2.Assert(asm is not null && !UTF8String.IsNullOrEmpty(asm.Culture));
            if (asm is null || UTF8String.IsNullOrEmpty(asm.Culture))
            {
                return(null);
            }
            var name    = FileUtils.RemoveExtension(rsrcName);
            var ext     = FileUtils.GetExtension(rsrcName);
            var locName = name + "." + asm.Culture + ext;
            var er      = module.Resources.OfType <EmbeddedResource>().FirstOrDefault(a => StringComparer.Ordinal.Equals(a.Name, locName));
            var set     = TryCreateResourceElementSet(module, er);

            if (set is null)
            {
                return(null);
            }
            Debug2.Assert(er is not null);

            var dirName = Path.GetDirectoryName(nonSatFile.Filename) !;
            var dir     = Directory.Length + 1 > dirName.Length ? string.Empty : dirName.Substring(Directory.Length + 1);

            name = Path.GetFileNameWithoutExtension(nonSatFile.Filename);
            ext  = Path.GetExtension(nonSatFile.Filename);
            var filename = filenameCreator.CreateFromRelativePath(Path.Combine(dir, name) + "." + asm.Culture, ext);

            return(CreateResXFile(module, er, set, filename, string.Empty, true));
        }
Exemplo n.º 3
0
		IEnumerable<ProjectFile> CreateSatelliteFiles(string rsrcName, FilenameCreator filenameCreator, ProjectFile nonSatFile) {
			foreach (var satMod in satelliteAssemblyFinder.GetSatelliteAssemblies(Options.Module)) {
				var satFile = TryCreateSatelliteFile(satMod, rsrcName, filenameCreator, nonSatFile);
				if (satFile != null)
					yield return satFile;
			}
		}
Exemplo n.º 4
0
 IEnumerable <ProjectFile> CreateSatelliteFiles(string rsrcName, FilenameCreator filenameCreator, ProjectFile nonSatFile)
 {
     foreach (var satMod in satelliteAssemblyFinder.GetSatelliteAssemblies(Options.Module))
     {
         var satFile = TryCreateSatelliteFile(satMod, rsrcName, filenameCreator, nonSatFile);
         if (satFile is not null)
         {
             yield return(satFile);
         }
     }
 }