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

C# ScriptScope类代码示例

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

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



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

示例1: StartServer

        /// <summary>
        /// Publish objects so that the host can use it, and then block indefinitely (until the input stream is open).
        /// 
        /// Note that we should publish only one object, and then have other objects be accessible from it. Publishing
        /// multiple objects can cause problems if the client does a call like "remoteProxy1(remoteProxy2)" as remoting
        /// will not be able to know if the server object for both the proxies is on the same server.
        /// </summary>
        /// <param name="remoteRuntimeChannelName">The IPC channel that the remote console expects to use to communicate with the ScriptEngine</param>
        /// <param name="scope">A intialized ScriptScope that is ready to start processing script commands</param>
        internal static void StartServer(string remoteRuntimeChannelName, ScriptScope scope) {
            Debug.Assert(ChannelServices.GetChannel(remoteRuntimeChannelName) == null);

            IpcChannel channel = CreateChannel("ipc", remoteRuntimeChannelName);

            LifetimeServices.LeaseTime = GetSevenDays();
            LifetimeServices.LeaseManagerPollTime = GetSevenDays();
            LifetimeServices.RenewOnCallTime = GetSevenDays();
            LifetimeServices.SponsorshipTimeout = GetSevenDays();

            ChannelServices.RegisterChannel(channel, false);

            try {
                RemoteCommandDispatcher remoteCommandDispatcher = new RemoteCommandDispatcher(scope);
                RemotingServices.Marshal(remoteCommandDispatcher, CommandDispatcherUri);

                // Let the remote console know that the startup output (if any) is complete. We use this instead of
                // a named event as we want all the startup output to reach the remote console before it proceeds.
                Console.WriteLine(RemoteCommandDispatcher.OutputCompleteMarker);

                // Block on Console.In. This is used to determine when the host process exits, since ReadLine will return null then.
                string input = System.Console.ReadLine();
                Debug.Assert(input == null);
            } finally {
                ChannelServices.UnregisterChannel(channel);
            }
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:36,代码来源:RemoteRuntimeServer.cs


示例2: Execute

        public object Execute(CompiledCode compiledCode, ScriptScope scope) {
            Debug.Assert(_executingThread == null);
            _executingThread = Thread.CurrentThread;

            try {
                object result = compiledCode.Execute(scope);

                Console.WriteLine(RemoteCommandDispatcher.OutputCompleteMarker);

                return result;
            } catch (ThreadAbortException tae) {
                KeyboardInterruptException pki = tae.ExceptionState as KeyboardInterruptException;
                if (pki != null) {
                    // Most exceptions get propagated back to the client. However, ThreadAbortException is handled
                    // differently by the remoting infrastructure, and gets wrapped in a RemotingException
                    // ("An error occurred while processing the request on the server"). So we filter it out
                    // and raise the KeyboardInterruptException
                    Thread.ResetAbort();
                    throw pki;
                } else {
                    throw;
                }
            } finally {
                _executingThread = null;
            }
        }
开发者ID:jcteague,项目名称:ironruby,代码行数:26,代码来源:RemoteCommandDispatcher.cs


示例3: Execute

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


示例4: SendMethodToModules

 public static void SendMethodToModules(string methodName, ScriptScope scope)
 {
     var engine = scope.Engine;
       var snippet = String.Format(RecompileSnippet, methodName);
       var source = engine.CreateScriptSourceFromString(snippet, SourceCodeKind.Statements);
       source.Execute(scope);
 }
开发者ID:trietptm,项目名称:retoolkit,代码行数:7,代码来源:ScriptHelper.cs


示例5: RenderView

        private void RenderView(ScriptScope scope, ViewContext context, TextWriter writer)
        {
            scope.SetVariable("view_data", context.ViewData);
            scope.SetVariable("model", context.ViewData.Model);
            scope.SetVariable("context", context);
            scope.SetVariable("response", context.HttpContext.Response);
            scope.SetVariable("url", new RubyUrlHelper(context.RequestContext));
            scope.SetVariable("html", new RubyHtmlHelper(context, new Container(context.ViewData)));
            scope.SetVariable("ajax", new RubyAjaxHelper(context, new Container(context.ViewData)));

            var script = new StringBuilder();
            Template.ToScript("render_page", script);

            if (_master != null)
                _master.Template.ToScript("render_layout", script);
            else
                script.AppendLine("def render_layout; yield; end");

            script.AppendLine("def view_data.method_missing(methodname); get_Item(methodname.to_s); end");
            script.AppendLine("render_layout { |content| render_page }");

            try
            {
                _rubyEngine.ExecuteScript(script.ToString(), scope);
            }
            catch (Exception e)
            {
                writer.Write(e.ToString());
            }
        }
开发者ID:jdhardy,项目名称:ironrubymvc,代码行数:30,代码来源:RubyView.cs


示例6: Run

 public void Run(ScriptScope scope)
 {
     if (scope == ScriptScope.CurrentFile)
         RunFile();
     else if (scope == ScriptScope.AllOpenFiles)
         RunAllFiles();
 }
开发者ID:rally25rs,项目名称:npp-DotNetScripting,代码行数:7,代码来源:ScriptRunner.cs


示例7: Execute

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


示例8: PythonSingleLayer

        public PythonSingleLayer(PythonScriptHost host, string code, string name)
        {
            Name = name;
            Code = code;
            Host = host;

            string[] codeWithoutWhitespace = code.Split(new char[] { ' ', '\n' }, StringSplitOptions.RemoveEmptyEntries);
            string alltokens = "";

            foreach (string token in codeWithoutWhitespace)
            {
                alltokens += token;
            }

            _id = alltokens.GetHashCode().ToString();

            _scope = host.CreateScriptSource(code, name);

            if (_scope.ContainsVariable(_processannotations))
            {
                _processAnnotationsFunc = _scope.GetVariable(_processannotations);
            }

            if (_scope.ContainsVariable(_interpret))
            {
                _interpretFunc = _scope.GetVariable(_interpret);
            }
        }
开发者ID:prefab,项目名称:code,代码行数:28,代码来源:PythonSingleLayer.cs


示例9: Main

        /// <summary>
        /// Main method
        /// </summary>
        /// <param name="args">Command line args.</param>
        public static void Main(string[] args)
        {
            engine = Python.CreateEngine();
            scope = engine.CreateScope();

            engine.Runtime.LoadAssembly(typeof(TurntableBot).Assembly);
            engine.Runtime.LoadAssembly(typeof(JObject).Assembly);
            engine.Runtime.IO.RedirectToConsole();

            ScriptSource source = null;

            if (File.Exists(Script))
            {
                source = engine.CreateScriptSourceFromFile(Script);
            }
            else
            {
                Console.WriteLine("File not found");
            }

            if (source != null)
            {
                try
                {
                    source.Execute(scope);
                }
                catch (Exception e)
                {
                    ExceptionOperations ops = engine.GetService<ExceptionOperations>();
                    Console.WriteLine(ops.FormatException(e));
                }
            }

            Console.ReadLine();
        }
开发者ID:nmalaguti,项目名称:Turntable-API-sharp,代码行数:39,代码来源:Program.cs


示例10: PythonScriptReader

        public PythonScriptReader()
        {
            _engine = Python.CreateEngine();
            _escope = _engine.CreateScope();

            var reader = new StreamReader(new FileStream(@"Scripts\Script.py", FileMode.Open, FileAccess.Read));
            string scriptText = reader.ReadToEnd();
            reader.Close();

            _engine.Execute(scriptText, _escope);

            if (!_escope.TryGetVariable("GeneratorFunc", out _randomGenerator))
            {
                MessageBox.Show("Error Occurred in Executing python script! - GeneratorFunc", "Error");
                throw new Exception("Error Occurred in Executing python script!");
            }
            if (!_escope.TryGetVariable("userDefinedFunc", out _userDefinedMethod))
            {
                MessageBox.Show("Error Occurred in Executing python script! - userDefinedFunc", "Error");
                throw new Exception("Error Occurred in Executing python script!");
            }
            if (!_escope.TryGetVariable("LifeSpanMapper", out _lifeTimeMapper))
            {
                MessageBox.Show("Error Occurred in Executing python script! - LifeSpanMapper", "Error");
                throw new Exception("Error Occurred in Executing python script!");
            }
            if (!_escope.TryGetVariable("DelayMapper", out _delayTimeMapper))
            {
                MessageBox.Show("Error Occurred in Executing python script! - DelayMapper", "Error");
                throw new Exception("Error Occurred in Executing python script!");
            }
        }
开发者ID:taesiri,项目名称:Simulation,代码行数:32,代码来源:PythonScriptReader.cs


示例11: PythonLanguage

 public PythonLanguage()
 {
     _scope = Python.CreateEngine().CreateScope();
       _scope.Engine.Runtime.LoadAssembly(typeof(string).Assembly);
       _scope.Engine.Runtime.LoadAssembly(typeof(Uri).Assembly);
       _scope.Engine.Runtime.LoadAssembly(typeof(SPList).Assembly);
 }
开发者ID:butaji,项目名称:Sapphire,代码行数:7,代码来源:PythonLanguage.cs


示例12: Engine

 public Engine()
 {
     Dictionary<String,Object> options = new Dictionary<string,object>();
     options["DivisionOptions"] = PythonDivisionOptions.New;
     engine = Python.CreateEngine(options);
     scope = engine.CreateScope();
 }
开发者ID:rachmatg,项目名称:ironpython,代码行数:7,代码来源:Class1.cs


示例13: InitialzeInterpreter

        /// <summary>
        /// 初始化解释器
        /// </summary>
        public void InitialzeInterpreter()
        {
            pythonEngine = Python.CreateEngine();
            pythonScope = pythonEngine.CreateScope();

            string initialString =
            @"
            import clr, sys
            import System.Collections.Generic.List as List
            clr.AddReference('Clover')
            from Clover import *
            # 获取CloverController的实例
            clover = CloverController.GetInstance();
            # 取出所有的函数指针
            FindFacesByVertex = clover.FindFacesByVertex
            GetVertex = clover.GetVertex
            CutFaces = clover.AnimatedCutFaces
            _CutFaces = clover.CutFaces
            _RotateFaces = clover.RotateFaces
            RotateFaces = clover.AnimatedRotateFaces
            Undo = clover.Undo
            Redo = clover.Redo
            ";

            pythonEngine.Execute(initialString, pythonScope);
        }
开发者ID:cedricporter,项目名称:Clover,代码行数:29,代码来源:CloverInterpreter.cs


示例14: PyInterpretUtility

 public PyInterpretUtility()
 {
     _engine = Python.CreateEngine();
     _stdout = new MemoryStream();
     _engine.Runtime.IO.SetOutput(_stdout, Encoding.ASCII);
     _scope = null;
 }
开发者ID:TeamRedInc,项目名称:red-inc,代码行数:7,代码来源:PyInterpretUtility.cs


示例15: Load

        public override void Load(string code = "")
        {
            Engine = IronPython.Hosting.Python.CreateEngine();
            Scope = Engine.CreateScope();
            Scope.SetVariable("Commands", chatCommands);
            Scope.SetVariable("DataStore", DataStore.GetInstance());
            Scope.SetVariable("Find", Find.GetInstance());
            Scope.SetVariable("GlobalData", GlobalData);
            Scope.SetVariable("Plugin", this);
            Scope.SetVariable("Server", Pluton.Server.GetInstance());
            Scope.SetVariable("ServerConsoleCommands", consoleCommands);
            Scope.SetVariable("Util", Util.GetInstance());
            Scope.SetVariable("Web", Web.GetInstance());
            Scope.SetVariable("World", World.GetInstance());
            try {
                Engine.Execute(code, Scope);
                Class = Engine.Operations.Invoke(Scope.GetVariable(Name));
                Globals = Engine.Operations.GetMemberNames(Class);

                object author = GetGlobalObject("__author__");
                object about = GetGlobalObject("__about__");
                object version = GetGlobalObject("__version__");
                Author = author == null ? "" : author.ToString();
                About = about == null ? "" : about.ToString();
                Version = version == null ? "" : version.ToString();

                State = PluginState.Loaded;
            } catch (Exception ex) {
                Logger.LogException(ex);
                State = PluginState.FailedToLoad;
            }

            PluginLoader.GetInstance().OnPluginLoaded(this);
        }
开发者ID:Notulp,项目名称:Pluton,代码行数:34,代码来源:PYPlugin.cs


示例16: RubyHelper

        public RubyHelper()
        {
            Scope = Engine.CreateScope();

            Engine.SetSearchPaths
            LoadRubyFiles();
        }
开发者ID:mickdelaney,项目名称:mickdelaney,代码行数:7,代码来源:RubyHelper.cs


示例17: EditorDocument

        public EditorDocument(string input = "")
        {
            if (input == "")
            {
                Title = "Untitled";
                SavedBefore = false;
            }
            else
            {
                Title = Path.GetFileName(input);
                SavedBefore = true;
                InputFile = input;
            }

            _ruby = Settings.RubyTemplate;
            _scope = Settings.ScopeTemplate;

            var editor = Settings.ScintillaTemplate;
            
            if (input != "")
                editor.Text = File.ReadAllText(input);

            Content = new WindowsFormsHost
            {
                Child = editor
            };
        }
开发者ID:furesoft,项目名称:Mathos-Project,代码行数:27,代码来源:EditorDocument.cs


示例18: RubyEngine

        /// <summary>
        /// Initializes a new instance of the <see cref="Distribox.CommonLib.RubyEngine"/> class.
        /// </summary>
        public RubyEngine()
        {
            this.scope = this.engine.CreateScope();

            // warm up
            this.DoString("0");
        }
开发者ID:hoangvv1409,项目名称:codebase,代码行数:10,代码来源:RubyEngine.cs


示例19: LoadCoreModule

        /// <summary>
        /// Load the core module that offers access to the simulation environment.
        /// </summary>
        public void LoadCoreModule()
        {
            scope = engine.CreateScope();

            // Allow scriptable access to...
            scope.SetVariable("status", Program.form.toolStripStatus);  // Statusbar.
            scope.SetVariable("log", Program.form.txtLog); // Simulation log.
            try
            {
                e_script = engine.CreateScriptSourceFromFile("syeon.py");
                e_script.Execute(scope);
            }
            catch(Exception e)
            {
                DialogResult ans = MessageBox.Show(
                e.Message, SSE, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
                if(ans == DialogResult.Abort)
                {
                    Program.form.Close();
                }
                else if(ans == DialogResult.Retry)
                {
                    LoadCoreModule(); // Recursion rules!
                }
            }
        }
开发者ID:stpettersens,项目名称:Syeon,代码行数:29,代码来源:ScriptingEngine.cs


示例20: PythonTF

 public PythonTF()
 {
     engine = Python.CreateEngine();
     scope = engine.CreateScope();
     Script = "value";
     ScriptWorkMode = ScriptWorkMode.不进行转换;
 }
开发者ID:CHERRISHGRY,项目名称:Hawk,代码行数:7,代码来源:PythonTF.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# ScriptState类代码示例发布时间:2022-05-24
下一篇:
C# ScriptProcessor类代码示例发布时间: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