我需要在后面的代码中读取整个 resx 文件。我是这样做的:
ResXResourceReader rsxrOrganizationSubtypes = new ResXResourceReader(@"D:\DNN_Cafaas\DesktopModules\OPEGIEKA.DNN.Modules.CreateInstitution\App_LocalResources\OrganizationSubtypes.resx");
rsxrOrganizationSubtypes.UseResXDataNodes = true;
IDictionaryEnumerator dict = rsxrOrganizationSubtypes.GetEnumerator();
while (dict.MoveNext())
{
ResXDataNode node = (ResXDataNode)dict.Value;
}
是否有可能对 resx 文件中的结果进行排序/排序?例如按名称?
已解决(按 resx 文件中的值排序)。也许有更好的方法来做到这一点,但它的工作原理:
ResXResourceReader rsxr = new ResXResourceReader(PathToResX);
rsxr.UseResXDataNodes = true;
IDictionaryEnumerator dictRSXR = rsxr.GetEnumerator();
SortedDictionary<string, string> sortedRSXR = new SortedDictionary<string, string>();
while (dictRSXR.MoveNext())
{
ResXDataNode node = (ResXDataNode)dictRSXR.Value;
sortedRSXR.Add(node.GetValue((ITypeResolutionService)null).ToString(), node.Name);
}
foreach (KeyValuePair<string, string> p in sortedRSXR)
{
counterDDL++;
dropDownList.Items.Insert(counterDDL, new ListItem(p.Key, p.Value));
}