X-Ray Resonant Magnetic Scattering Study of Magnetic Structures and Magnetic Switching Mechanism in Magnetic Multilayers and Nanostructures