public void SaveEnvironmentsIfDirty() { if (!_environmentIsDirty) { return; } _environmentIsDirty = false; lock (SourceDirectories) { //rebuild the model tree AppDataManager.SaveEnvironments(SourceDirectories.Select(vm => vm.RegenerateModel()).ToList()); } }