Add example code. Introduced polymorphism for resources marshaling.