Dynamical Theory of X-Ray Diffraction