private string PromiseRequire(JsFunction func)
        {
            return
                (@"function(extraArgs){ 
    return new Promise(function(resolve){
        require(['{moduleNames}'], function({moduleVars}){
            {moduleVars}.{functionName}({arguments}).then(function(args) { resolve(args); });
        });
    });
}".Replace("{moduleNames}", func.Module.Name)
                 .Replace("{moduleVars}", JsFunction.VarName(func.Module))
                 .Replace("{functionName}", func.FunctionName)
                 .Replace("{arguments}", func.Arguments.ToString(a => a == ClientConstructorManager.ExtraJsonParams ? "extraArgs" : JsonConvert.SerializeObject(a, func.JsonSerializerSettings), ", ")));
        }