• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ScriptEngine类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: HookUpScript

        internal void HookUpScript(string scriptLanguage) {

            if (scriptLanguage == null) {
                // TODO: Need to revise this, we need to use the InvariantContext here probably
                // but it can't actually do calls yet.
                _scriptEngine = _defaultEngine;
                return;
            }

            _scriptEngine = EngineHelper.GetScriptEngineByName(scriptLanguage);
            _defaultEngine = _defaultEngine ?? _scriptEngine;

            _templateControlVirtualPath = VirtualPathUtility.ToAbsolute(_templateControl.AppRelativeVirtualPath);

            // First, look for a code behind file named <pagename>.aspx.<ext>, where 'ext' is the extension
            // for the page's language
            _inlineScript = false;
            IList<string> extensions = _scriptEngine.Setup.FileExtensions;
            foreach (string extension in extensions) {
                _scriptVirtualPath = _templateControlVirtualPath + extension;
                if (HookUpScriptFile()) {
                    return;
                }
            }

            // Then, look for inline script
            _inlineScript = true;
            _scriptVirtualPath = _templateControlVirtualPath;
            HookUpScriptFile();
        }
开发者ID:nieve,项目名称:ironruby,代码行数:30,代码来源:ScriptTemplateControl.cs


示例17: JSBlockType

    public JSBlockType(ScriptEngine engine, string name)
        : base(engine)
    {
        this.PopulateFunctions();

        this.name = name;
    }
开发者ID:dallonf,项目名称:WorldScript,代码行数:7,代码来源:JSBlockType.cs


示例18: ReadAllTasks

        public static ICollection<string> ReadAllTasks(string path)
        {
            var list = new List<string>();

            if (path.EndsWith(".ts"))
            {
                path = path.Replace(".ts", ".js").Replace(".coffee",".js");
            }

            if (!File.Exists(path))
            {
                return list;
            }

            // executes the gulpfile with some little additions :)
            try
            {
                var engine = new ScriptEngine();
                engine.Execute(Resources.gulpInit);
                engine.ExecuteFile(path);

                // reads the evaluated tasks
                ArrayInstance names = (ArrayInstance)engine.Evaluate("tasks");
                foreach (var elem in names.ElementValues)
                {
                    list.Add((string)elem);
                }
            }
            catch (Exception)
            {
                list.Add("Cannot parse gulpfile");
            }

            return list.Distinct().ToList();
        }
开发者ID:brucethwaits,项目名称:GruntLauncher,代码行数:35,代码来源:GulpParser.cs


示例19: Execute

 public override void Execute(ScriptEngine engine, ScriptScope scope)
 {
     if (!string.IsNullOrEmpty(Path))
     {
         engine.ExecuteFile(Path, scope);
     }
 }
开发者ID:torshy,项目名称:FileReplicator,代码行数:7,代码来源:ScriptFile.cs


示例20: ClrStaticTypeWrapper

        /// <summary>
        /// Creates a new ClrStaticTypeWrapper object.
        /// </summary>
        /// <param name="engine"> The associated script engine. </param>
        /// <param name="type"> The CLR type to wrap. </param>
        /// <param name="flags"> <c>BindingFlags.Static</c> to populate static methods;
        /// <c>BindingFlags.Instance</c> to populate instance methods. </param>
        private ClrStaticTypeWrapper(ScriptEngine engine, Type type)
            : base(engine, GetPrototypeObject(engine, type))
        {
            this.WrappedType = type;

            // Pick up the public constructors, if any.
            var constructors = type.GetConstructors();
            if (constructors.Length > 0)
                this.constructBinder = new ClrBinder(constructors);
            else
            {
                // The built-in primitive types do not have constructors, but we still want to
                // allow their construction since there is no way to construct them otherwise.
                // Pretend that a constructor does exist.
                switch (Type.GetTypeCode(type))
                {
                    case TypeCode.Int32:
                        this.constructBinder = new ClrBinder(ReflectionHelpers.Convert_ToInt32_Double);
                        break;
                }
            }

            this.FastSetProperty("name", type.Name);
            if (this.constructBinder != null)
                this.FastSetProperty("length", this.constructBinder.FunctionLength);

            // Populate the fields, properties and methods.
            PopulateMembers(this, type, BindingFlags.Static);
        }
开发者ID:HaKDMoDz,项目名称:GNet,代码行数:36,代码来源:ClrStaticTypeWrapper.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ScriptExecutionContext类代码示例发布时间:2022-05-24
下一篇:
C# ScriptCsArgs类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap