当前位置: 首页>>代码示例>>C#>>正文


C# ScriptEngine类代码示例

本文整理汇总了C#中ScriptEngine的典型用法代码示例。如果您正苦于以下问题:C# ScriptEngine类的具体用法?C# ScriptEngine怎么用?C# ScriptEngine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ScriptEngine类属于命名空间,在下文中一共展示了ScriptEngine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateScriptEngineWithCoffeeScriptLoaded

 static ScriptEngine CreateScriptEngineWithCoffeeScriptLoaded()
 {
     var engine = new ScriptEngine();
     engine.Execute(Properties.Resources.coffeescript);
     engine.Execute("function compile(c) { return CoffeeScript.compile(c); }");
     return engine;
 }
开发者ID:prabirshrestha,项目名称:cassette,代码行数:7,代码来源:JurassicCoffeeScriptCompiler.cs

示例2: __GETTER__ToStringTag

 private static object __GETTER__ToStringTag(ScriptEngine engine, object thisObj, object[] args)
 {
     thisObj = TypeConverter.ToObject(engine, thisObj);
     if (!(thisObj is SetIterator))
         throw new JavaScriptException(engine, ErrorType.TypeError, "The method 'get [Symbol.toStringTag]' is not generic.");
     return ((SetIterator)thisObj).ToStringTag;
 }
开发者ID:paulbartrum,项目名称:jurassic,代码行数:7,代码来源:SetIterator.g.cs

示例3: __GETTER__ByteLength

 private static object __GETTER__ByteLength(ScriptEngine engine, object thisObj, object[] args)
 {
     thisObj = TypeConverter.ToObject(engine, thisObj);
     if (!(thisObj is ArrayBufferInstance))
         throw new JavaScriptException(engine, ErrorType.TypeError, "The method 'get byteLength' is not generic.");
     return ((ArrayBufferInstance)thisObj).ByteLength;
 }
开发者ID:paulbartrum,项目名称:jurassic,代码行数:7,代码来源:ArrayBufferInstance.g.cs

示例4: ToString

 public override string ToString(ScriptEngine engine)
 {
     string msg = engine.Pad() + "Return" + Environment.NewLine;
     engine.IndentationLevel += ScriptEngine.PaddingIncrement;
     msg += engine.Pad() + "LHS:" + Environment.NewLine;
     {
         engine.IndentationLevel += ScriptEngine.PaddingIncrement;
         for (int i = 0; i < _lhs.Count; i++)
         {
             msg += _lhs[i].ToString(engine);
         }
         engine.IndentationLevel -= ScriptEngine.PaddingIncrement;
     }
     msg += engine.Pad() + "RHS:" + Environment.NewLine;
     {
         engine.IndentationLevel += ScriptEngine.PaddingIncrement;
         for (int i = 0; i < _rhs.Count; i++)
         {
             msg += _rhs[i].ToString(engine);
         }
         engine.IndentationLevel -= ScriptEngine.PaddingIncrement;
     }
     engine.IndentationLevel -= ScriptEngine.PaddingIncrement;
     return msg;
 }
开发者ID:iammitch,项目名称:Slimterpreter,代码行数:25,代码来源:EqualsToken.cs

示例5: ResponseInstance

 public ResponseInstance(ScriptEngine engine, HttpListenerResponse response)
     : base(engine)
 {
     this.Response = response;
     this.PopulateFields();
     this.PopulateFunctions();
 }
开发者ID:tmcnab,项目名称:RaptorJS,代码行数:7,代码来源:ResponseInstance.cs

示例6: FunctionMethodGenerator

 /// <summary>
 /// Creates a new FunctionContext instance.
 /// </summary>
 /// <param name="engine"> The script engine. </param>
 /// <param name="scope"> The function scope. </param>
 /// <param name="functionName"> The name of the function. </param>
 /// <param name="argumentNames"> The names of the arguments. </param>
 /// <param name="body"> The source code for the body of the function. </param>
 /// <param name="options"> Options that influence the compiler. </param>
 public FunctionMethodGenerator(ScriptEngine engine, DeclarativeScope scope, string functionName, IList<string> argumentNames, string body, CompilerOptions options)
     : base(engine, scope, new StringScriptSource(body), options)
 {
     this.Name = functionName;
     this.ArgumentNames = argumentNames;
     this.BodyText = body;
 }
开发者ID:benliddicott,项目名称:JS360,代码行数:16,代码来源:FunctionMethodGenerator.cs

示例7: GetDeclarativeProperties

 private static List<PropertyNameAndValue> GetDeclarativeProperties(ScriptEngine engine)
 {
     return new List<PropertyNameAndValue>(4)
     {
         new PropertyNameAndValue(engine.Symbol.Species, new PropertyDescriptor(new ClrStubFunction(engine.FunctionInstancePrototype, "get [Symbol.species]", 0, __GETTER__Species), null, PropertyAttributes.Configurable)),
     };
 }
开发者ID:paulbartrum,项目名称:jurassic,代码行数:7,代码来源:MapConstructor.g.cs

示例8: __GETTER__Species

 private static object __GETTER__Species(ScriptEngine engine, object thisObj, object[] args)
 {
     thisObj = TypeConverter.ToObject(engine, thisObj);
     if (!(thisObj is MapConstructor))
         throw new JavaScriptException(engine, ErrorType.TypeError, "The method 'get [Symbol.species]' is not generic.");
     return ((MapConstructor)thisObj).Species;
 }
开发者ID:paulbartrum,项目名称:jurassic,代码行数:7,代码来源:MapConstructor.g.cs

示例9: Build

        public override Token Build(Token lastToken, ScriptEngine engine, Script script, ref SourceCode sourceCode)
        {
            while ((++sourceCode).SpecialChar)
            {
            }
            if (sourceCode.Peek() != '{')
            {
                sourceCode.Throw(String.Format("Error parsing a 'do' statement, expected a '{' but got '{0}' instead.",
                                               sourceCode.Peek()));
            }
            List<List<List<Token>>> code = engine.BuildLongTokens(ref sourceCode, ref script, new[] {'}'});

            if (!sourceCode.SeekToNext("while"))
            {
                sourceCode.Throw("Error parsing a 'do' statement, was expecting a 'while' after the { } block.");
            }

            if (!sourceCode.SeekToNext('('))
            {
                sourceCode.Throw("Error parsing a 'do' statement, was expecting a '(' after 'while'.");
            }

            List<List<Token>> exitCondition = engine.BuildTokensAdvanced(ref sourceCode, ref script, new[] {')'});

            return new DoWhileToken(code, exitCondition);
        }
开发者ID:iammitch,项目名称:Slimterpreter,代码行数:26,代码来源:DoWhileBlockBuilder.cs

示例10: JavaScriptException

 /// <summary>
 /// Creates a new JavaScriptException instance.
 /// </summary>
 /// <param name="name"> The name of the error, e.g "RangeError". </param>
 /// <param name="message"> A description of the error. </param>
 /// <param name="lineNumber"> The line number in the source file the error occurred on. </param>
 /// <param name="sourcePath"> The path or URL of the source file.  Can be <c>null</c>. </param>
 public JavaScriptException(ScriptEngine engine, string name, string message, int lineNumber, string sourcePath)
     : base(string.Format("{0}: {1}", name, message))
 {
     this.ErrorObject = CreateError(engine, name, message);
     this.LineNumber = lineNumber;
     this.SourcePath = sourcePath;
 }
开发者ID:HaKDMoDz,项目名称:GNet,代码行数:14,代码来源:JavaScriptException.cs

示例11: RequireJsCompiler

        public RequireJsCompiler(TextWriter consoleOut, string currentDirectory)
        {
            _jsEngine = new ScriptEngine();
            _jsEngine.CompatibilityMode = CompatibilityMode.ECMAScript3;

            _jsEngine.Evaluate(LoadResource("require.js"));
            _jsEngine.Evaluate(LoadResource("json2.js"));
            _jsEngine.Evaluate(LoadResource(@"adapt\rhino.js"));

            _jsEngine.Evaluate("require(" + new JavaScriptSerializer().Serialize(new {
                baseUrl = ResourceBaseUrl
            }) + ");");

            _fs = new NativeFS(_jsEngine, currentDirectory);
            _jsEngine.SetGlobalValue("YUNoFS", _fs);

            _path = new NativePath(_jsEngine, currentDirectory);
            _jsEngine.SetGlobalValue("YUNoPath", _path);

            _ioAdapter = new IOAdapter(_jsEngine, consoleOut);

            _jsEngine.SetGlobalFunction("load", (Action<string>)_ioAdapter.load);

            _jsEngine.SetGlobalValue("ioe", _ioAdapter);
            _jsEngine.SetGlobalValue("IsRunningYUNoAMD", true);

            SetupModuleFromResource(RequireJsCompiler.ResourceBaseUrl + "env.js", @"build\jslib\env.js");
            SetupModuleFromResource(RequireJsCompiler.ResourceBaseUrl + "yunoamd/args.js", @"build\jslib\yunoamd\args.js");
            SetupModuleFromResource(RequireJsCompiler.ResourceBaseUrl + "build.js", @"build\build.js");
            SetupModuleFromResource(RequireJsCompiler.ResourceBaseUrl + "print.js", @"build\jslib\yunoamd\print.js");
            SetupModuleFromResource(RequireJsCompiler.ResourceBaseUrl + "fs.js", @"build\jslib\yunoamd\fs.js");
            SetupModuleFromResource(RequireJsCompiler.ResourceBaseUrl + "path.js", @"build\jslib\yunoamd\path.js");
            SetupModuleFromResource(RequireJsCompiler.ResourceBaseUrl + "file.js", @"build\jslib\node\file.js");
        }
开发者ID:fschwiet,项目名称:YUNoAMD,代码行数:34,代码来源:RequireJsCompiler.cs

示例12: Meta

 internal Meta(ScriptEngine engine, ModelInstance instance)
     : base(engine, engine.Object.InstancePrototype)
 {
     this.PopulateFunctions();
     this.instance = instance;
     this.typeWrapper = new TypeWrapper(engine, instance.Type);
 }
开发者ID:vc3,项目名称:ExoWeb,代码行数:7,代码来源:Meta.cs

示例13: __STUB__ToLocaleString

 private static object __STUB__ToLocaleString(ScriptEngine engine, object thisObj, object[] args)
 {
     thisObj = TypeConverter.ToObject(engine, thisObj);
     if (!(thisObj is NumberInstance))
         throw new JavaScriptException(engine, ErrorType.TypeError, "The method 'toLocaleString' is not generic.");
     return ((NumberInstance)thisObj).ToLocaleString();
 }
开发者ID:paulbartrum,项目名称:jurassic,代码行数:7,代码来源:NumberInstance.g.cs

示例14: __STUB__ValueOf

 private static object __STUB__ValueOf(ScriptEngine engine, object thisObj, object[] args)
 {
     thisObj = TypeConverter.ToObject(engine, thisObj);
     if (!(thisObj is SymbolInstance))
         throw new JavaScriptException(engine, ErrorType.TypeError, "The method 'valueOf' is not generic.");
     return ((SymbolInstance)thisObj).ValueOf();
 }
开发者ID:paulbartrum,项目名称:jurassic,代码行数:7,代码来源:SymbolInstance.g.cs

示例15: __STUB__Call

 private static object __STUB__Call(ScriptEngine engine, object thisObj, object[] args)
 {
     thisObj = TypeConverter.ToObject(engine, thisObj);
     if (!(thisObj is MapConstructor))
         throw new JavaScriptException(engine, ErrorType.TypeError, "The method 'Call' is not generic.");
     return ((MapConstructor)thisObj).Call();
 }
开发者ID:paulbartrum,项目名称:jurassic,代码行数:7,代码来源:MapConstructor.g.cs


注:本文中的ScriptEngine类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。