我有两个大型资源文件,我必须将它们合并。两个文件中可能存在一些相同的Name属性
<data name="SomeResource" xml:space="preserve">
<value> The resource value </value>
</data>
如何获取相同的所有资源名称?如果某些条目具有相同的值,那么这不是问题,但是同名是一个问题。
答案 0 :(得分:3)
您可以使用小型控制台应用程序来获取所有重复的资源名称:
using System;
using System.Collections;
using System.Globalization;
using System.Linq;
class Program
{
static void Main(string[] args)
{
//replace with your strongly typed resource classes
var rm1 = MyApplication.Properties.Resources.ResourceManager;
var rm2 = MyApplication.Properties.Resources1.ResourceManager;
var rs1 = rm1.GetResourceSet(CultureInfo.CurrentUICulture, true, true);
var rs2 = rm2.GetResourceSet(CultureInfo.CurrentUICulture, true, true);
var result = from re1 in rs1.Cast<DictionaryEntry>()
join re2 in rs2.Cast<DictionaryEntry>()
on re1.Key equals re2.Key
select new { re1, re2 };
foreach (var item in result)
{
Console.Write("Key with name \"{0}\" is present in ",
item.re1.Key);
Console.WriteLine("both files (\"{0}\" and \"{1}\")",
item.re1.Value, item.re2.Value);
}
}
}