5 using System.Collections.Generic;
7 using SiliconStudio.Core;
9 namespace SiliconStudio.Assets.Compiler
17 private readonly Dictionary<Type, T> typeToCompiler =
new Dictionary<Type, T>();
22 public T DefaultCompiler {
get; set; }
31 if (compiler == null)
throw new ArgumentNullException(
"compiler");
33 AssertAssetType(type);
35 typeToCompiler[type] = compiler;
45 AssertAssetType(type);
47 if (!typeToCompiler.ContainsKey(type))
48 return DefaultCompiler;
50 return typeToCompiler[type];
53 private static void AssertAssetType(Type assetType)
55 if (assetType == null)
56 throw new ArgumentNullException(
"assetType");
58 if (!typeof(
Asset).IsAssignableFrom(assetType))
59 throw new ArgumentException(
"Type [{0}] must be assignable to Asset".ToFormat(assetType),
"assetType");
T GetCompiler(Type type)
Gets the compiler associated to an Asset type.
void RegisterCompiler(Type type, T compiler)
Register a compiler for a given Asset type.
Main interface for compiling an Asset.