public Project ReadProject(FileInfo projectFile) { // Make sure we have a sane state. if (projectFile == null) { throw new ArgumentNullException("projectFile"); } // Query the plugins to determine which persistence plugins are capable // of reading this project. var validPlugins = new List<IPersistencePlugin>(); foreach (IPersistencePlugin persistencePlugin in plugin.PersistentPlugins.Where( persistencePlugin => persistencePlugin.CanRead(projectFile))) { validPlugins.Add(persistencePlugin); } // If we don't have a plugin, then we have nothing that will open it. if (validPlugins.Count == 0) { throw new FileLoadException("Cannot load the project file: " + projectFile); } // If we have more than one plugin, we can't handle it. if (validPlugins.Count > 1) { throw new FileLoadException( "Too many plugins claim they can read the file: " + projectFile); } // Pass the loading process to the actual plugin we'll be using. IPersistencePlugin persistentPlugin = validPlugins[0]; Project project = persistentPlugin.ReadProject(projectFile); return project; }
public ForExpression Persistence(IPersistencePlugin plugin) { _pluginConfiguration.Register(plugin); return(this); }