- 授权协议: Ms-PL
- 开发语言: C#
- 操作系统: Windows
- 软件首页: http://clearscript.codeplex.com/
软件介绍
ClearScript 可以帮助开发者添加脚本到 .NET 应用,当前支持 JavaScript (V8 和 JScript) 和 VBScript。
示例
using System;
using Microsoft.ClearScript;
using Microsoft.ClearScript.V8;
// create a script engine
using (var engine = new V8ScriptEngine())
{
// expose a host type
engine.AddHostType("Console", typeof(Console));
engine.Execute("Console.WriteLine('{0} is an interesting number.', Math.PI)");
// expose a host object
engine.AddHostObject("random", new Random());
engine.Execute("Console.WriteLine(random.NextDouble())");
// expose entire assemblies
engine.AddHostObject("lib", new HostTypeCollection("mscorlib", "System.Core"));
engine.Execute("Console.WriteLine(lib.System.DateTime.Now)");
// create a host object from script
engine.Execute(@"
birthday = new lib.System.DateTime(2007, 5, 22);
Console.WriteLine(birthday.ToLongDateString());
");
// use a generic class from script
engine.Execute(@"
Dictionary = lib.System.Collections.Generic.Dictionary;
dict = new Dictionary(lib.System.String, lib.System.Int32);
dict.Add('foo', 123);
");
// call a host method with an output parameter
engine.AddHostObject("host", new HostFunctions());
engine.Execute(@"
intVar = host.newVar(lib.System.Int32);
found = dict.TryGetValue('foo', intVar.out);
Console.WriteLine('{0} {1}', found, intVar);
");
// create and populate a host array
engine.Execute(@"
numbers = host.newArr(lib.System.Int32, 20);
for (var i = 0; i < numbers.Length; i++) { numbers[i] = i; }
Console.WriteLine(lib.System.String.Join(', ', numbers));
");
// create a script delegate
engine.Execute(@"
Filter = lib.System.Func(lib.System.Int32, lib.System.Boolean);
oddFilter = new Filter(function(value) {
return (value & 1) ? true : false;
});
");
// use LINQ from script
engine.Execute(@"
oddNumbers = numbers.Where(oddFilter);
Console.WriteLine(lib.System.String.Join(', ', oddNumbers));
");
// use a dynamic host object
engine.Execute(@"
expando = new lib.System.Dynamic.ExpandoObject();
expando.foo = 123;
expando.bar = 'qux';
delete expando.foo;
");
// call a script function
engine.Execute("function print(x) { Console.WriteLine(x); }");
engine.Script.print(DateTime.Now.DayOfWeek);
// examine a script object
engine.Execute("person = { name: 'Fred', age: 5 }");
Console.WriteLine(engine.Script.person.name);
}数据驱动:从方法到实践
桑文锋 / 电子工业出版社 / 2018-3 / 49
本书是从理论到实践的全面且细致的企业数据驱动指南,从作者的百度大数据工作说起,完整还原其从零到一构建百度用户行为大数据处理平台经历。详解大数据本质、理念与现状,围绕数据驱动四环节——采集、建模、分析、指标,深入浅出地讲述企业如何将数据驱动方案落地,并指出数据驱动的价值在于“数据驱动决策”、“数据驱动产品智能”。最后通过互联网金融、电子商务、企业服务、零售四大行业实践,从需求梳理、事件指标设计、数据......一起来看看 《数据驱动:从方法到实践》 这本书的介绍吧!
