Generalized methodology for control of long-lived nuclear spin order in magnetic resonance