public static IMovementCommand ToCreateOrMergePatchMovement <TCreateMovement, TMergePatchMovement, TCreateMovementLine, TMergePatchMovementLine>(this IMovementState state) where TCreateMovement : ICreateMovement, new() where TMergePatchMovement : IMergePatchMovement, new() where TCreateMovementLine : ICreateMovementLine, new() where TMergePatchMovementLine : IMergePatchMovementLine, new() { bool bUnsaved = ((IMovementState)state).IsUnsaved; if (bUnsaved) { return(state.ToCreateMovement <TCreateMovement, TCreateMovementLine>()); } else { return(state.ToMergePatchMovement <TMergePatchMovement, TCreateMovementLine, TMergePatchMovementLine>()); } }