Use dynamic_pointer_cast instead of casting for shared_ptr

Change-Id: Iff41b8f81cdbf06493235b451d63372e52818808