2013-10-29 4 views
1

코드 뒤에 전체 resx 파일을 읽을 필요가 있습니다. 나는 이렇게했습니다 :ResXResourceReader에서 데이터를 정렬/정렬 할 수 있습니까?

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 파일에서 결과를 정렬/정렬 할 수 있습니까? 예를 들어 Name?

해결 (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));         
} 

답변

1

당신은 while 루프에서 SortedDictionary<string, ResXDataNode>에 키와 값을 추가 할 수 있습니다. 이렇게하면 항목이 자동으로 정렬됩니다.

+0

감사합니다. 정말 도움이되었습니다. 내 게시물을 편집하고 동일한 문제가있는 사람을 위해 해결 방법을 추가했습니다. :) –

관련 문제