Game Development Reference
This problem could be solved by compiling the abstract loader interface into a sep-
arate assembly, along with both loader types compiled into their own assemblies.
The texture browser component and both loaders would reference the abstract
loader interface, and the texture browser component would dynamically reference
the appropriate loader at runtime using reflection.
With such a problem, you are probably wondering why the component was not
designed to accommodate this decoupling in the first place. Reflection and plug-
in-based architectures would be the ideal “best practice” way to design the com-
ponent, but this chapter is meant to cover how to build the component itself,
hence why the component was designed the way it is. Removing this dependency
on Direct3D can be done two ways, both very easily. You can exclude the Direct3D
loader code from the texture browser component and recompile it; do not forget
to remove the assembly references as well. Or you can refactor the component to
support a plugin-based architecture, which is covered in Chapter 38, “Designing
an Extensible Plugin-Based Architecture.”
Overall, this chapter presents a solid and reusable component that can be employed
in a number of tools.