Factoring:  Materials derived classes have their contents type.

Use internal static_cast to dispatch the write material to the
resource_manager.
This enables us to avoid duplicate code that does the same thing.
Maybe not the best method, but a current solution until I found a better
solution.