Edge for C#

Edge for C#
refer: https://github.com/tjanczuk/edge/tree/master#scripting-nodejs-from-clr

Note: After building NodeJs code by VS no need deploy the js code, because the js code alreay building in dll.

Windows

Node.js 0.8.x or later (developed and tested with v0.8.22, and v0.10.0, both x32 and x64 architectures)
.NET 4.5
to use Python, you also need IronPython 2.7.3 or later
to use F#, read Dave Thomas blog post

How to: use external Node.js modules

You can use external Node.js modules, for example modules installed from NPM.
Note: Most Node.js modules are written in JavaScript and will execute in Edge as-is. However, some Node.js external modules are native binary modules, rebuilt by NPM on module installation to suit your local execution environment. Native binary modules will not run in Edge unless they are rebuilt to link against the NodeJS dll that Edge uses.
To install modules from NPM, you must first install Node.js on your machine and use the npm package manager that comes with the Node.js installation. NPM modules must be installed in the directory where your build system places the Edge.js NuGet package (most likely the same location as the rest of your application binaries), or any ancestor directory. Alternatively, you can install NPM modules globally on the machine using npm install -g:

coding: (NodeJs code should under building fold /node_modules )
public ActionResult Index()
{
Task.Run((Action)test).Wait();
return View();

}
public async void test()
{
var func = Edge.Func(@" return function(path){// var Fontmin = require('fontmin');// var fontmin = new Fontmin().src(path).dest('d:\\')// .use(Fontmin.ttf2woff({// clone: true,// deflate: true // }));// fontmin.run(function (err, files) {// if (err) {// throw err;// } console.log(files[0]);// // }); var Woffmin = require('woffmin'); // Woffmin.aa(path); Woffmin.towoff(path); }; ");
try
{
await func("d:\\ariblk.ttf");
}
catch(Exception e){
string aa = e.Message;
}


var woffmin = require('./woffmin/woffmin');
var font = require('fontmin');

exports.towoff = function (path) {
woffmin.towoff(path);
};

---------------------------------------------------------------------------------------------------------------------
var Fontmin = require('fontmin');

exports.towoff = function (path) {
var fontmin = new Fontmin().src(path).dest('d:\\')
.use(Fontmin.ttf2woff({
clone: true,
deflate: true
}));
fontmin.run(function (err, files) {
if (err) {
throw err;
}
});
};
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值