I have a separate application (that is for the purpose of spell checking my .resx files) that runs as a pre-build event. However, if the .resx file contains a text file (xml for example) my application will load the file and attempt to spell check it. This is not really what I want it to do. Is there a way to tell from the ResXResourceReader if the resource loaded is actually a file?
Code sample looks like this:
ResXResourceReader reader = new ResXResourceReader(filename);
ResourceSet resourceset = new ResourceSet(reader);
Dictionary<DictionaryEntry, object> newvalues = new Dictionary<DictionaryEntry, object>();
foreach (DictionaryEntry entry in resourceset)
{
//Figure out in this 'if' if it is an embedded file and should be ignored.
if (entry.Key.ToString().StartsWith(">>") || !(entry.Value is string) || string.Compare((string)entry.Value, "---") == 0)
continue;
}
The . resx resource file format consists of XML entries that specify objects and strings inside XML tags. One advantage of a . resx file is that when opened with a text editor (such as Notepad) it can be written to, parsed, and manipulated.
Navigate to resources from File Structure Open a . resx file in the XML (Text) editor. Press Ctrl+Alt+F or choose ReSharper | Windows | File Structure from the main menu . Alternatively, you can press Ctrl+Shift+A , start typing the command name in the popup, and then choose it there.
Net Resource (. resx) files are a monolingual file format used in Microsoft . Net Applications. The . resx resource file format consists of XML entries, which specify objects and strings inside XML tags.
Yes. Setting UseResXDataNodes
on ResXResourceReader
will cause the dictionary values to be a ResXDataNode
instead of the actual value, which you can use to determine if it is a file or not. Something like this:
var rsxr = new ResXResourceReader("Test.resx");
rsxr.UseResXDataNodes = true;
foreach (DictionaryEntry de in rsxr)
{
var node = (ResXDataNode)de.Value;
//FileRef is null if it is not a file reference.
if (node.FileRef == null)
{
//Spell check your value.
var value = node.GetValue((ITypeResolutionService) null);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With