A general approach for determining the diffraction contrast factor of straight-line dislocations