我需要编写一个程序,该程序从dll读取所有字符串资源并将它们插入某个表中。我有方法,读取资源:从资源管理器获取所有字符串
private static IEnumerable<KeyValuePair<string,string>> getAllResources(ResourceManager resourceManager,
Language language)
{
ResourceSet resourceSet = resourceManager.GetResourceSet(getCulture(language), true, true);
IDictionaryEnumerator dictNumerator = resourceSet.GetEnumerator();
// Get all string resources
while (dictNumerator.MoveNext())
{
// Only string resources
if (dictNumerator.Value is string)
{
var key = (string)dictNumerator.Key;
var value = (string)dictNumerator.Value;
yield return new KeyValuePair<string, string>(key, value);
}
}
}
但是当我开始使用它,我注意到,它也读出资源,像文件添加(读取文件内容)
我怎能无视作为“文件”添加的资源,以及只读字符串?
难道不可能在值上使用'as'铸造吗? –
我可以使用“as”而不是“is”,但它不能解决我的问题 – Oleksey