private static void ProcessFile(String inFile, String outFile, ResourceClassOptions resourceClassOptions, bool useSourcePath) {
//Console.WriteLine("Processing {0} --> {1}", inFile, outFile);
// Reset state
resources.Clear();
resourcesHashTable.Clear();
try {
// Explicitly handle missing input files here - don't catch a
// FileNotFoundException since we can get them from the loader
// if we try loading an assembly version we can't find.
if (!File.Exists(inFile)) {
Error(SR.GetString(SR.FileNotFound, inFile));
return;
}
ReadResources(inFile, useSourcePath);
}
catch (ArgumentException ae) {
if (ae.InnerException is XmlException) {
XmlException xe = (XmlException) ae.InnerException;
Error(xe.Message, inFile, xe.LineNumber, xe.LinePosition);
}
else {
Error(ae.Message, inFile);
}
return;
}
catch (TextFileException tfe) {
// Used to pass back error context from ReadTextResources to here.
Error(tfe.Message, tfe.FileName, tfe.LineNumber, tfe.LinePosition);
return;
}
catch (Exception e) {
Error(e.Message, inFile);
// We need to give meaningful error messages to the user.
// Note that ResXResourceReader wraps any exception it gets
// in an ArgumentException with the message "Invalid ResX input."
// If you don't look at the InnerException, you have to attach
// a debugger to find the problem.
if (e.InnerException != null) {
Exception inner = e.InnerException;
StringBuilder sb = new StringBuilder(200);
sb.Append(e.Message);
while (inner != null) {
sb.Append(" ---> ");
sb.Append(inner.GetType().Name);
sb.Append(": ");
sb.Append(inner.Message);
inner = inner.InnerException;
}
Error(SR.GetString(SR.SpecificError, e.InnerException.GetType().Name, sb.ToString()), inFile);
}
return;
}
try {
WriteResources(outFile);
}
catch (IOException io) {
Error(SR.GetString(SR.WriteError, outFile), outFile);
if (io.Message != null)
Error(SR.GetString(SR.SpecificError, io.GetType().Name, io.Message), outFile);
if (File.Exists(outFile)) {
Error(SR.GetString(SR.CorruptOutput, outFile));
try {
File.Delete(outFile);
}
catch (Exception) {
Error(SR.GetString(SR.DeleteOutputFileFailed, outFile));
}
}
return;
}
catch (Exception e) {
Error(SR.GetString(SR.GenericWriteError, outFile));
if (e.Message != null)
Error(SR.GetString(SR.SpecificError, e.GetType().Name, e.Message));
}
}