public void RegisterImporter <T, U>() where U : ContentImporter <T> { if (Importers.ContainsKey(typeof(U))) { return; // TODO: Throw/log something in future? } Importers.Add(typeof(T), Activator.CreateInstance <U>()); }
public T Load <T>(string relativePath) where T : class { var completePath = Path.Combine(ContentRoot, relativePath); if (!File.Exists(completePath)) { throw new ContentPathException(completePath, "Could not find a file at the provided path."); } var type = typeof(T); if (!Importers.ContainsKey(type)) { throw new ContentUnsupportedException(type, "The requested type has no importers registered."); } return(Importers[type].ImportObject(completePath) as T); }