private static readonly bool UseStorage = true; // option from config file public static IEventManager CreateManager() { if (UseStorage) { var stg = new FileEventManager("events.txt"); var primary = new InMemoryManager(); return(new CombinedManager(primary, stg)); } else { return(new InMemoryManager()); } }
private void CopySourceToLocalFolder() { for (int assignmentIndex = 0; assignmentIndex < this.inputMapping.Count; assignmentIndex++) { ImportInputAssignment assignment = this.inputMapping.Data[assignmentIndex]; // Copy all handled files to the media / source directory try { // Copy each handled file into source / media, while preserving the original relative structure for (int i = 0; i < assignment.HandledInput.Length; i++) { string filePath = assignment.HandledInput[i].Path; string filePathInSourceMedia = assignment.HandledInputInSourceMedia[i].Path; string dirPathInSourceMedia = Path.GetDirectoryName(filePathInSourceMedia); // If the file is already where it needs to be, skip it if (PathOp.ArePathsEqual(filePath, filePathInSourceMedia)) { continue; } // If there already is a similarly named file in the source directory, delete it. if (File.Exists(filePathInSourceMedia)) { File.Delete(filePathInSourceMedia); } // Assure the media / source directory exists Directory.CreateDirectory(dirPathInSourceMedia); // Copy file from its original location to the source / media directory File.Copy(filePath, filePathInSourceMedia); // Let the editor know that this was an internal operation - don't handle it like an external operation FileEventManager.FlagPathEditorModified(filePathInSourceMedia); } } catch (Exception ex) { Logs.Editor.WriteError("Can't copy source files to the media / source directory: {0}", LogFormat.Exception(ex)); this.inputMapping.RemoveAt(assignmentIndex); assignmentIndex--; } } }
private bool RunImporter(AssetExportEnvironment env, ExportInputAssignment assignment, IList <string> outputPathCollection) { try { assignment.Importer.Export(env); // Get a list on properly registered output Resources and report warnings on the rest foreach (string outputPath in env.OutputPaths) { FileEventManager.FlagPathEditorModified(outputPath); if (!assignment.ExpectedOutput.Contains(outputPath)) { Log.Editor.WriteWarning( "AssetImporter '{0}' created an unpredicted output file: '{1}'. " + Environment.NewLine + "This may cause problems in the Asset Management system, especially during Asset re-import. " + Environment.NewLine + "Please fix the implementation of the PrepareExport method so it properly calls AddOutputPath for each predicted output file.", Log.Type(assignment.Importer.GetType()), outputPath); } else { outputPathCollection.Add(outputPath); } } } catch (Exception ex) { Log.Editor.WriteError("An error occurred while trying to export Resource '{2}' using '{1}': {0}", Log.Exception(ex), Log.Type(assignment.Importer.GetType()), env.Input); return(false); } return(true); }