using System; using System.Collections.Generic; using RecrownedGTK.AssetsSystem.Information; using RecrownedGTK.AssetsSystem.Loaders; namespace RecrownedGTK.AssetsSystem { public class AssetLoader { private readonly Dictionary typeLoaders; public AssetLoader() { typeLoaders = new Dictionary(); } public void AddLoaderResolver(Type type, ILoader loader) { if (typeLoaders.ContainsKey(type)) { throw new InvalidOperationException(String.Format("The type {0} already exists in this resolver.", type)); } typeLoaders.Add(type, loader); } public void RemoveLoaderResolver(Type type) { if (!typeLoaders.ContainsKey(type)) { throw new InvalidOperationException(String.Format("The type {0} doesn't exist in this resolver.", type)); } typeLoaders.Remove(type); } public IInfo Load(string path, Type type) { if (!typeLoaders.ContainsKey(type)) { throw new InvalidOperationException(String.Format("The type {0} doesn't exist in this resolver.", type)); } return typeLoaders[type].load(path); } } }