A new characterization of Dirichlet type spaces and applications