Handle missing ManufacturerNameMapping data from settings.json

This commit is contained in:
John Lewin 2015-11-13 18:29:39 -08:00
parent 797f6166a9
commit 70f3b7df68
2 changed files with 7 additions and 5 deletions

View file

@ -62,15 +62,16 @@ namespace MatterHackers.MatterControl
{
string folderName = Path.GetFileName(manufacturerDirectory.TrimEnd(new[] { '/', '\\' }));
foreach(ManufacturerNameMapping nameMapping in manufacturerNameMappings)
// Set manufacturer name to the directory name
this.manufacturer = Path.GetFileName(manufacturerDirectory);
// Override the manufacturer name if a manufacturerNameMappings exists
foreach (ManufacturerNameMapping nameMapping in manufacturerNameMappings)
{
if(nameMapping.NameOnDisk == folderName)
{
this.manufacturer = nameMapping.NameToDisplay;
}
else
{
this.manufacturer = Path.GetFileName(manufacturerDirectory);
break;
}
}

View file

@ -95,6 +95,7 @@ namespace MatterHackers.MatterControl.SettingsManagement
string pathToOemSettings = Path.Combine(".", "OEMSettings", "Settings.json");
File.WriteAllText(pathToOemSettings, JsonConvert.SerializeObject(this, Formatting.Indented));
#endif
this.ManufacturerNameMappings = new List<ManufacturerNameMapping>();
}
}