Harrison
d50ede989c
Loads information from loader. information creates useable. Minor folder restructuring. Untested.
31 lines
1.2 KiB
C#
31 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using RecrownedGTK.AssetsSystem.Information;
|
|
using RecrownedGTK.AssetsSystem.Loaders;
|
|
|
|
namespace RecrownedGTK.AssetsSystem {
|
|
public class AssetLoader {
|
|
private readonly Dictionary<Type, ILoader> typeLoaders;
|
|
public AssetLoader() {
|
|
typeLoaders = new Dictionary<Type, ILoader>();
|
|
}
|
|
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);
|
|
}
|
|
}
|
|
} |