我几乎完成了从这里获取的代码重构: https ://github.com/agracio/edge-js-quick-start
我添加了两个处理可重复代码的类,但我被困在两行代码中。我一辈子都想不通他们做了什么。我似乎也不明白 edge_app_root 的目标是什么(它是一个文件夹,但我怀疑它的目标是某个文件?)
进程.env.EDGE_USE_CORECLR = 1; process.env.EDGE_APP_ROOT = baseNetAppPath;
const path = require('path');
var version = process.argv[2];
// print process.argv
process.argv.forEach((val, index) =>
{
console.log(+index + ":" + val);
});
console.log();
//by default the core will be used (and standard is not supported)
var namespace = 'QuickStart.' + version.charAt(0).toUpperCase() + version.substr(1);
if (version === 'core')
{
version = 'coreapp';
console.log("coreapp");
}
const baseNetAppPath = path.join(__dirname, '/src/' + namespace + '/bin/Debug/net' + version + '2.0');
process.env.EDGE_USE_CORECLR = 1;
if (version !== 'standard')
{
console.log("version is not standard")
process.env.EDGE_APP_ROOT = baseNetAppPath;
console.log("process.env.EDGE_APP_ROOT:\n" + baseNetAppPath+"\n");
}
var edge = require('edge-js');
var baseDll = path.join(baseNetAppPath, namespace + '.dll');
console.log(`basedll: ${baseDll}`);
//load functions from namespaces.cs files
var localTypeName = namespace + '.LocalMethods';
var namespace2 = namespace + '.InnerMethods';
console.log(`Using basedll:${baseDll}\n namespace2:${namespace2}\n`);
var getList = edge.func({
assemblyFile: baseDll,//should be the same
typeName: namespace2,//namespace + '.InnerMethods',
methodName: "GetList"
});
getList('', function (error, result)
{
if (error) throw error;
console.log(namespace + '.InnerMethods');
console.log(result + "\n");
});
谢谢你的时间!