예제 #1
0
        // Attempt to import another type of movie file into a movie object.
        public static ImportResult ImportFile(IMovieSession session, IEmulator emulator, string path, Config config)
        {
            string ext          = Path.GetExtension(path) ?? "";
            var    importerType = ImporterForExtension(ext);

            if (importerType == default)
            {
                return(ImportResult.Error($"No importer found for file type {ext}"));
            }

            // Create a new instance of the importer class using the no-argument constructor
            IMovieImport importer = (IMovieImport)importerType
                                    .GetConstructor(new Type[] { })
                                    ?.Invoke(new object[] { });

            return(importer == null
                                ? ImportResult.Error($"No importer found for file type {ext}")
                                : importer.Import(session, emulator, path, config));
        }