Ejemplo n.º 1
0
 private ScriptController CreateController()
 {
     _controller = new ScriptController(false);
     //  _controller.Engine.Runtime.LoadAssembly(typeof(System.Diagnostics.Process).Assembly);
     _controller.OnMessage += new MessageEvent(_controller_OnMessage);
     return(_controller);
 }
Ejemplo n.º 2
0
        public Program()
        {
            TitleArt();
            SetupCommands();
            LoadConfigurations();

#if DEBUG
            scriptController = new ScriptController("../../Util/Extending/Scripts/");
#else
            scriptController = new ScriptController("scripts/");
#endif
            scriptController.LoadScripts();
            scriptController.Scripts.ForEach(t => t.Load());

            StartServers();

            while (true)
            {
                Thread.Sleep(1);
                string input = Console.ReadLine();
                if (input.Equals("exit"))
                {
                    break;
                }
            }

            scriptController.Scripts.ForEach(t => t.Unload());
            scriptController.UnloadScripts();

            Config.SaveConfiguration();
            Logger.Log("Configuration", "Successfully saved {0} configurations.", Logger.LogLevel.Config, Config.Count);

            Console.Read();
        }
Ejemplo n.º 3
0
        public WinConditionChecker(AutoController scene)
        {
            scene.Components.GetOrRegister <Message <Board> >((int)ComponentKeys.BoardCreatedMessage, Message <Board> .Create)
            .Subscribe(new SimpleListener <Board>((b) => board = b));
            db               = scene.Game.Components.Get <GameDatabase>((int)ComponentKeys.GameDatabase);
            scripts          = scene.Game.Components.Get <ScriptController>((int)ComponentKeys.LuaScripts);
            actionCalculator = scene.Components.GetOrRegister <Query <TurnOptions, TurnOptionCalculatorArgs> >
                                   ((int)ComponentKeys.MoveOptionListQuery, Query <TurnOptions, TurnOptionCalculatorArgs> .Create);
            nextTurnInfo = scene.Components.GetOrRegister <Query <NextTurnInfo> >((int)ComponentKeys.NextTurnInfoQuery, Query <NextTurnInfo> .Create);

            lastCalcState = new MoveCalcState();
            optionCache   = new Dictionary <int, Mods.Lua.PieceTurnOptions>();
            luaHelper     = new Mods.Lua.WinLossHelper();
            luaHelper.QPlayerHasPieces = new Query <bool, string>(CheckHasPieces);
            luaHelper.QGetTurnOptions  = new Query <Mods.Lua.PieceTurnOptions, Mods.Lua.Piece>(GetTurnOptions);
            luaHelper.QPlayerCanMove   = new Query <bool, string>(CheckCanMove);
            luaHelperValue             = UserData.Create(luaHelper);

            turnOptionsHasOptions = new Query <bool, PieceTurnOptions>(CheckTurnOptionsHasAny);
            turnOptionsCanMove    = new Query <bool, PieceTurnOptions, IntVector2>(CheckTurnOptionsCanMove);
            turnOptionsCanCapture = new Query <bool, PieceTurnOptions, IntVector2>(CheckTurnOptionsCanCapture);
            turnOptionsCanPromote = new Query <bool, PieceTurnOptions, IntVector2>(CheckTurnOptionsCanPromote);

            scene.Components.GetOrRegister <Query <EoTScriptState> >
                ((int)ComponentKeys.GameOverQuery, Query <EoTScriptState> .Create).Handler = CheckGameOver;
        }
Ejemplo n.º 4
0
        public void CreateShouldReturnCreatedID()
        {
            var newScene = new Scene()
            {
                ID = 1
            };
            var newScript = new Script()
            {
                ID = 1
            };
            var newScriptCreate = new ScriptCreate {
                PilotID = 1,
                Scenes  = new List <SceneCreate> {
                    new SceneCreate()
                }
            };

            _aviMock.Setup(x => x.AddScene(It.IsAny <Scene>())).Returns(newScene);
            _aviMock.Setup(x => x.AddScript(It.IsAny <Script>())).Returns(newScript);

            var newAviqtorBL = new ScriptController(_aviMock.Object, _blobSC);
            var result       = newAviqtorBL.Create(newScriptCreate);

            Assert.IsAssignableFrom <CreatedID>(result);
            Assert.Equal(result.ID, newScriptCreate.PilotID);
            _aviMock.Verify(x => x.AddScene(It.IsAny <Scene>()));
        }
Ejemplo n.º 5
0
        protected override void OnShutdown()
        {
            if (m_scriptController != null)
            {
                m_scriptController.Dispose();
                m_scriptController = null;
            }

            Game.Screen.Elements.Remove(m_placementPreview);
            m_placementPreview.Dispose();
            m_placementPreview = null;

            Game.Screen.Elements.Remove(m_placementPreviewText);
            m_placementPreviewText.Dispose();
            m_placementPreviewText = null;

            Game.Screen.Elements.Remove(m_titleText);
            m_titleText.Dispose();
            m_titleText = null;

            if (m_dialog != null)
            {
                Game.Screen.Elements.Remove(m_dialog);
                if (m_disposeDialogOnClose)
                {
                    m_dialog.Dispose();
                }
                m_dialog = null;
            }
        }
Ejemplo n.º 6
0
        public TurnManager(ChessScene scene)
        {
            //db = scene.Game.Components.Get<GameDatabase>((int)ComponentKeys.GameDatabase);
            scene.Components.GetOrRegister <Message <Board> >((int)ComponentKeys.BoardCreatedMessage, Message <Board> .Create)
            .Subscribe(new SimpleListener <Board>((b) => board = b));
            startTurnChoosingCommand = scene.Components.GetOrRegister <Command>
                                           ((int)ComponentKeys.StartTurnChoosingCommand, Command.Create);
            stopTurnChoosingCommand = scene.Components.GetOrRegister <Command>
                                          ((int)ComponentKeys.StopTurnChoosingCommand, Command.Create);
            scene.Components.GetOrRegister <Query <NextTurnInfo> >((int)ComponentKeys.NextTurnInfoQuery, Query <NextTurnInfo> .Create)
            .Handler    = FigureNextTurn;
            moveCommand = scene.Components.GetOrRegister <Command <MoveCommand> >
                              ((int)ComponentKeys.MovePieceCommand, Command <MoveCommand> .Create);
            captureCommand = scene.Components.GetOrRegister <Command <CaptureCommand> >
                                 ((int)ComponentKeys.CapturePieceCommand, Command <CaptureCommand> .Create);
            promoteCommand = scene.Components.GetOrRegister <Command <PromoteCommand> >
                                 ((int)ComponentKeys.PromotePieceCommand, Command <PromoteCommand> .Create);
            scene.Components.GetOrRegister <Message <TurnAction> >((int)ComponentKeys.MoveChoiceMadeEvent, Message <TurnAction> .Create)
            .Subscribe(new SimpleListener <TurnAction>(HandleChoiceMade));
            scene.Components.GetOrRegister <Command <bool> >((int)ComponentKeys.NextTurnCommand, Command <bool> .Create).Handler = NextTurnCommand;
            scripts         = scene.Game.Components.Get <ScriptController>((int)ComponentKeys.LuaScripts);
            handleEndOfTurn = scene.Components.GetOrRegister <Command <TurnActionExecutionResult> >
                                  ((int)ComponentKeys.HandleEndOfTurn, Command <TurnActionExecutionResult> .Create);
            turnChange = scene.Components.GetOrRegister <Message>((int)ComponentKeys.TurnChange, Message.Create);

            scene.Components.GetOrRegister <Message>((int)ComponentKeys.TurnState, Message.Create)
            .Subscribe(new SimpleListener(OnTurnStateChange));
            connectionState = scene.Components.GetOrRegister <StateMachine>((int)ComponentKeys.ReconnectionState, StateMachine.Create);
            connectionState.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => OnConnectionStateChange()));
        }
Ejemplo n.º 7
0
        public async Task CreateShouldReturnCreatedID()
        {
            var newScene = new Scene()
            {
                ID = 1
            };
            var newScript = new Script()
            {
                ID = 1
            };
            var ccMock          = new Mock <BlobContainerClient>();
            var bcMock          = new Mock <BlobClient>();
            var newScriptCreate = new ScriptCreate {
                PilotID = 1,
                Scenes  = new List <SceneCreate> {
                    new SceneCreate()
                }
            };

            _aviMock.Setup(x => x.AddScene(It.IsAny <Scene>())).Returns(newScene);
            _aviMock.Setup(x => x.AddScript(It.IsAny <Script>())).Returns(newScript);
            // _bscMock.Setup(x => x.CreateBlobContainer(It.IsAny<string>())).Returns(ccMock);

            var newAviqtorBL = new ScriptController(_aviMock.Object, _bscMock.Object);
            var result       = newAviqtorBL.Create(newScriptCreate);

            Assert.IsAssignableFrom <CreatedID>(result);
            Assert.Equal(result.ID, newScriptCreate.PilotID);
            _aviMock.Verify(x => x.AddScene(It.IsAny <Scene>()));
        }
Ejemplo n.º 8
0
        IScriptContext getTest1Context()
        {
            var fn = "test01.py";

            var engine = new ScriptController(true);
            var ctx    = engine.CreateScriptContextFromFile(fn);

            return(ctx);
        }
        public GameStartGenerator(ModLoadingScene scene)
        {
            lobby   = scene.Game.Components.Get <LobbyChoices>((int)ComponentKeys.LobbyChoices);
            db      = scene.Game.Components.Get <GameDatabase>((int)ComponentKeys.GameDatabase);
            scripts = scene.Game.Components.Get <ScriptController>((int)ComponentKeys.LuaScripts);

            scene.Components.GetOrRegister((int)ComponentKeys.CalculateStartConditions, Query <NetworkGameState> .Create)
            .Handler = CalculateStartingConditions;
        }
Ejemplo n.º 10
0
        private void OnScriptControllerStatusUpdated(ScriptController controller)
        {
            if (InvokeRequired)
            {
                Invoke((ScriptControllerStatusUpdatedHandler)OnScriptControllerStatusUpdated, controller);
                return;
            }

            UpdateScriptControllerStatus(controller);
        }
Ejemplo n.º 11
0
        public object[] Eval(IRpcContext context, List <string> Args)
        {
            GetParams(Args);
            _controller = BeginProcess(_processName);
            var ctx = _controller.CreateScriptContextFromString(_code);

            ctx.Execute();

            //code.Run(_controller.Scope);
            return(new object[0]);
        }
Ejemplo n.º 12
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Ejemplo n.º 13
0
 private void UpdateScriptControllerStatus(ScriptController controller)
 {
     foreach (DataGridViewRow row_obj in Rows)
     {
         if (row_obj.Tag.Equals(controller))
         {
             UpdateScriptControllerStatus(row_obj, controller);
             return;
         }
     }
 }
        public TurnOptionCalculator(ChessScene scene)
        {
            scripts = scene.Game.Components.Get <ScriptController>((int)ComponentKeys.LuaScripts);
            db      = scene.Game.Components.Get <GameDatabase>((int)ComponentKeys.GameDatabase);
            scene.Components.GetOrRegister <Message <Board> >((int)ComponentKeys.BoardCreatedMessage, Message <Board> .Create)
            .Subscribe(new SimpleListener <Board>((b) => board = b));
            luaHelper = UserData.Create(new Mods.Lua.TurnActionHelper());

            scene.Components.GetOrRegister <Query <TurnOptions, TurnOptionCalculatorArgs> >
                ((int)ComponentKeys.MoveOptionListQuery, Query <TurnOptions, TurnOptionCalculatorArgs> .Create)
            .Handler = CalculateMoveOptions;
        }
Ejemplo n.º 15
0
 private ScriptController BeginProcess(string ProcessName)
 {
     lock (_processControllers)
     {
         if (!_processControllers.TryGetValue(ProcessName, out _controller))
         {
             _controller = CreateController();
             _processControllers[ProcessName] = _controller;
         }
         return(_controller);
     }
 }
Ejemplo n.º 16
0
        public void Run()
        {
            // var code = new StreamReader(Resources.ResourceManager.GetStream("TextFile1.py")).ReadToEnd();
            _controller            = new ScriptController(false);
            _controller.OnMessage += (sender, message) =>
            {
                //Console.WriteLine(message);
                // Console.WriteLine(String.Format("[{0:HH:MM:ss:fff}][SCRIPT]:{1}", DateTime.Now, message.Trim()));
                Console.WriteLine(String.Format("{0}", message.Trim()));
            };
            var            code    = Resources.ResourceManager.GetString("ScriptHeader1");
            dynamic        handler = null;
            IScriptContext ctx;

            try
            {
                if (string.IsNullOrEmpty(script))
                {
                    script = code;
                    ctx    = _controller.CreateScriptContextFromString(script);
                    ctx.Execute();
                }
                else
                {
                    ctx = _controller.CreateScriptContextFromFile(script);
                    ctx.ExecuteString(code);
                    ctx.Execute();
                }



                handler = ctx.Scope.CreateHandler();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return;
            }


            _mainProcess = new PyProcessContext(ctx, handler,
                                                _processFactory,
                                                command,
                                                CommandArguments,
                                                workingDirectory,
                                                _commandParameters);


            _mainProcess.Start();

            ctx.FlushBuffer();
            // Console.ReadKey();
        }
Ejemplo n.º 17
0
        public void TestPyEngine()
        {
            //var ctx = engine.CreateScriptContextFromString("def test(): return 10 + globalAdd");
            //var fn = @"z:\Dev\Andre\Libraries\AndresCSharpResource\UnitTests\ACSR.Code.PythonScripting.UnitTests\Test01.py";
            var fn = "test01.py";

            var engine = new ScriptController(true);
            var ctx = engine.CreateScriptContextFromFile(fn);
            ctx.Scope.globalAdd = 10;
            var code = ctx.Execute();
            var retVal = ctx.Scope.test(10);
            Assert.AreEqual(ctx.Scope.globalAdd + 10, retVal);
        }
Ejemplo n.º 18
0
 private void RegisterAsyncPostBackControls()
 {
     if (ScriptController != null)
     {
         ScriptController.RegisterAsyncPostBackControl(btnShowResults);
         ScriptController.RegisterAsyncPostBackControl(rblOptions);
         ScriptController.RegisterAsyncPostBackControl(btnBackToVote);
     }
     else
     {
         log.Error("ScriptController was null");
     }
 }
            public GetScript()
            {
                // Mock the hosting environment
                var hostingEnvironment = new Mock <IHostingEnvironment>();

                hostingEnvironment.Setup(m => m.WebRootPath).Returns(Directory.GetCurrentDirectory());

                // Create the controller instance
                this.controller = new ScriptController(hostingEnvironment.Object);

                // Create a file to test
                File.Open($"{Directory.GetCurrentDirectory()}/test.js", FileMode.OpenOrCreate).Dispose();
                File.SetLastWriteTimeUtc($"{Directory.GetCurrentDirectory()}/test.js", this.lastUpdate);
            }
Ejemplo n.º 20
0
        protected override void OnReveal()
        {
            base.OnReveal();

            // Add the GUI
            Game.Screen.Elements.Add(m_border);
            Game.Screen.Elements.AddBefore(m_terminal, m_border);

            // Start the cutscene
            if (ScriptController != null && ScriptController.HasFunction("run_cutscene"))
            {
                ScriptController.StartFunction("run_cutscene", LuaArgs.Empty);
            }
        }
Ejemplo n.º 21
0
        public void TestPyEngine()
        {
            //var ctx = engine.CreateScriptContextFromString("def test(): return 10 + globalAdd");
            //var fn = @"z:\Dev\Andre\Libraries\AndresCSharpResource\UnitTests\ACSR.Code.PythonScripting.UnitTests\Test01.py";
            var fn = "test01.py";

            var engine = new ScriptController(true);
            var ctx    = engine.CreateScriptContextFromFile(fn);

            ctx.Scope.globalAdd = 10;
            var code   = ctx.Execute();
            var retVal = ctx.Scope.test(10);

            Assert.AreEqual(ctx.Scope.globalAdd + 10, retVal);
        }
Ejemplo n.º 22
0
        private void LoadSettings()
        {
            pageID             = WebUtils.ParseInt32FromQueryString("pageid", -1);
            isSiteEditor       = SiteUtils.UserIsSiteEditor();
            pageHasAltContent1 = this.ContainsPlaceHolder("altContent1");
            pageHasAltContent2 = this.ContainsPlaceHolder("altContent2");

            try
            {
                // this keeps the action from changing during ajax postback in folder based sites
                SiteUtils.SetFormAction(Page, Request.RawUrl);
            }
            catch (MissingMethodException)
            {
                //this method was introduced in .NET 3.5 SP1
            }

            if (ScriptController != null)
            {
                ScriptController.RegisterAsyncPostBackControl(btnCreateNewContent);

                ScriptController.RegisterAsyncPostBackControl(LeftUpBtn);
                ScriptController.RegisterAsyncPostBackControl(LeftDownBtn);
                ScriptController.RegisterAsyncPostBackControl(ContentUpBtn);
                ScriptController.RegisterAsyncPostBackControl(ContentDownBtn);
                ScriptController.RegisterAsyncPostBackControl(RightUpBtn);
                ScriptController.RegisterAsyncPostBackControl(RightDownBtn);
                ScriptController.RegisterAsyncPostBackControl(btnAlt1MoveUp);
                ScriptController.RegisterAsyncPostBackControl(btnAlt1MoveDown);
                ScriptController.RegisterAsyncPostBackControl(btnAlt2MoveUp);
                ScriptController.RegisterAsyncPostBackControl(btnAlt2MoveDown);
                ScriptController.RegisterAsyncPostBackControl(LeftEditBtn);


                ScriptController.RegisterAsyncPostBackControl(LeftDeleteBtn);
                ScriptController.RegisterAsyncPostBackControl(ContentDeleteBtn);
                ScriptController.RegisterAsyncPostBackControl(RightDeleteBtn);
                ScriptController.RegisterAsyncPostBackControl(btnDeleteAlt1);
                ScriptController.RegisterAsyncPostBackControl(btnDeleteAlt2);
                ScriptController.RegisterAsyncPostBackControl(LeftRightBtn);
                ScriptController.RegisterAsyncPostBackControl(ContentLeftBtn);
                ScriptController.RegisterAsyncPostBackControl(ContentRightBtn);
                ScriptController.RegisterAsyncPostBackControl(RightLeftBtn);
                ScriptController.RegisterAsyncPostBackControl(btnMoveAlt1ToCenter);
                ScriptController.RegisterAsyncPostBackControl(btnMoveAlt1ToAlt2);
                ScriptController.RegisterAsyncPostBackControl(btnMoveAlt2ToAlt1);
            }
        }
        private void Page_Load(System.Object sender, System.EventArgs e)
        {
            ScriptController.InjectjQueryLibary(Page, false, false);
            ScriptController.InjectCssReference(Page, "mobiscroll", ResolveUrl("Resources/mobiscroll-1.6.min.css"), true, ScriptController.CssInjectOrder.f_Last);
            ScriptController.InjectJsLibrary(Page, "mobiscroll_js", ResolveUrl("Resources/mobiscroll-1.6.min.js"), false, ScriptController.ScriptInjectOrder.e_Default);

            var sb = new System.Text.StringBuilder();

            sb.AppendLine("<script type=\"text/javascript\">");
            sb.AppendLine("$(document).ready(function () {");
            sb.AppendLine(string.Format("$(\'#{0}\').scroller({{ preset: \'{1}\' , theme: \'{2}\', mode: \'{3}\' }});", txtMobiscroll.ClientID, MobiscrollSettings().Preset, MobiscrollSettings().Theme, MobiscrollSettings().Mode));
            sb.AppendLine("});");
            sb.AppendLine("</script>");

            Page.ClientScript.RegisterClientScriptBlock(GetType(), Unique("Mobiscroll"), sb.ToString());
        }
Ejemplo n.º 24
0
        public LevelState(Game game, string levelLoadPath, LevelOptions options) : base(game)
        {
            // Load level
            m_levelLoadPath = levelLoadPath;
            m_levelOptions  = options;
            var data = Assets.Get <LevelData>(m_levelLoadPath);

            m_level         = Dan200.Game.Level.Level.Load(data, m_levelOptions);
            m_level.Audio   = game.Audio;
            m_level.Visible = false;

            // Load GUI
            m_placementPreviewText               = new Text(UIFonts.Default, "", UIColours.Text, TextAlignment.Left);
            m_placementPreviewText.Visible       = false;
            m_placementPreviewText.Anchor        = Anchor.TopLeft;
            m_placementPreviewText.LocalPosition = new Vector2(
                96.0f + (this is EditorState ? 80.0f : 0.0f),
                32.0f
                );

            m_placementPreview               = new TileSelect(Game, Tile.Get(Level.Info.ItemPath));
            m_placementPreview.Visible       = false;
            m_placementPreview.Anchor        = Anchor.TopLeft;
            m_placementPreview.LocalPosition = new Vector2(
                48.0f + (this is EditorState ? 80.0f : 0.0f),
                48.0f
                );

            UpdatePlacementsLeft();
            EnableTimeEffects = true;

            m_titleText               = new Text(UIFonts.Default, "", UIColours.Text, TextAlignment.Right);
            m_titleText.Anchor        = Anchor.TopRight;
            m_titleText.LocalPosition = new Vector2(-24.0f, 16.0f);
            m_titleText.Visible       = false;

            m_dialog = null;
            m_disposeDialogOnClose = false;
            m_cameraController     = new InGameCameraController(Game);
            m_timeInState          = 0.0f;

            if (!m_level.Info.InEditor && m_level.Info.ScriptPath != null)
            {
                m_scriptController = new ScriptController(this);
            }
        }
Ejemplo n.º 25
0
        public object[] RunScript(IRpcContext context, string FileName, List <string> Args)
        {
            GetParams(Args);
            var args = _cmd.ParamsAfterSwitch("args");

            _context    = context;
            _fileName   = FileName;
            _args       = args;
            _controller = BeginProcess(_processName);

            //c.SearchPaths.Add(@"E:\Dev\Source\AndresIPyResource\Scripts");
            var ctx = _controller.CreateScriptContextFromFile(FileName);

            _controller.SetSysArgV(args);

            ctx.Execute();
            return(new object[0]);
        }
Ejemplo n.º 26
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.GetComponent <ScriptController>() != null)
     {
         ScriptController sc = other.gameObject.GetComponent <ScriptController>();
         for (int i = 0; i < sc.script.Length; i++)
         {
             (other.gameObject.GetComponent(sc.script[i]) as MonoBehaviour).enabled = true;
         }
     }
     if (other.tag == "Father")
     {
         foreach (Transform child in other.gameObject.transform)
         {
             Debug.Log("a0" + child.gameObject.name);
         }
     }
 }
Ejemplo n.º 27
0
        private void UpdateScriptControllerStatus(DataGridViewRow row_obj, ScriptController controller = null)
        {
            /* nullの場合はROWオブジェクトから復元 */
            if (controller == null)
            {
                controller = row_obj.Tag as ScriptController;
                if (controller == null)
                {
                    return;
                }
            }

            foreach (DataGridViewCell cell in row_obj.Cells)
            {
                switch ((ColumnId)cell.ColumnIndex)
                {
                case ColumnId.Mode:
                    cell.Value = controller.Mode;
                    break;

                case ColumnId.Status:
                    cell.Value = controller.Status;
                    break;

                case ColumnId.ScriptInfo:
                    cell.Value = controller.ToString();
                    break;
                }
            }

            switch (controller.Status)
            {
            case ScriptRunStatus.Running: row_obj.DefaultCellStyle.BackColor = Color.LightSkyBlue;    break;

            case ScriptRunStatus.Pause:   row_obj.DefaultCellStyle.BackColor = Color.LightYellow;     break;

            default:                      row_obj.DefaultCellStyle.BackColor = Color.White;           break;
            }

            row_obj.DefaultCellStyle.ForeColor          = Color.Black;
            row_obj.DefaultCellStyle.SelectionForeColor = row_obj.DefaultCellStyle.ForeColor;
            row_obj.DefaultCellStyle.SelectionBackColor = row_obj.DefaultCellStyle.BackColor;
        }
Ejemplo n.º 28
0
        private void ContentAction(DataGridViewRow row_obj, ColumnId column_id, ScriptController controller)
        {
            var cell_obj = row_obj.Cells[(int)column_id];

            switch (column_id)
            {
            case ColumnId.Mode:
            {
                controller.Mode = (ScriptRunMode)cell_obj.Value;
            }
            break;

            case ColumnId.Status:
            {
                controller.Status = (ScriptRunStatus)cell_obj.Value;
            }
            break;
            }
        }
Ejemplo n.º 29
0
        public IScriptContext Compile(string Code)
        {
            try
            {
                _engine  = new ScriptController(true);
                _context = _engine.CreateScriptContextFromString(Code, _context);
                foreach (var de in _variables)
                {
                    _context.SetVariable(de.Key, de.Value);
                }

                _engine.OnMessage += new MessageEvent(_engine_OnMessage);
                return(_context);
            }
            catch (Exception e)
            {
                LogMessage(e.Message);
                return(null);
            }
        }
Ejemplo n.º 30
0
    void CreateObjController()
    {
        if (objController == null)
        {
            string classname = this.GetType().ToString();
            objController = new GameObject(classname);
            RectTransform rctran = objController.AddComponent <RectTransform>();
            rctran.anchorMin = new Vector2(0, 0);
            rctran.anchorMax = new Vector2(1, 1);

            rctran.offsetMin = new Vector2(0, 0);
            rctran.offsetMax = new Vector2(0, 0);

            scriptController            = objController.AddComponent <ScriptController>();
            scriptController.controller = this;

            UpdateCanvasSize(AppSceneBase.main.sizeCanvas);
            ViewDidLoad();
        }
    }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                //note page load runs after LoadSettings(); because of dynamic control loading

                //now get the javascript in
                ScriptController.InjectjQueryLibary(this.Page, true, true);
                //module-specific jquery code
                ScriptController.InjectJsLibrary(this.Page, "nap", this.ControlPath + "/js/nap.js", true, ScriptController.ScriptInjectOrder.e_Default);
                //and get the css file in
                ScriptController.InjectCssReference(this.Page, "nap_css", this.ControlPath + "/newsarticlesprovider.css", true, ScriptController.CssInjectOrder.f_Last);
                //and put in a pre-dnn 6 ui script plus the jquery tabs library
                string preDnn6CssFile = this.ControlPath + "/ui-tabs.css";
                ScriptController.InjectjQueryTabsCss(this.Page, preDnn6CssFile, null);
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
Ejemplo n.º 32
0
        IScriptContext getTest1Context()
        {
            var fn = "test01.py";

            var engine = new ScriptController(true);
            var ctx = engine.CreateScriptContextFromFile(fn);
            return ctx;
        }
Ejemplo n.º 33
0
        public void Run()
        {
            // var code = new StreamReader(Resources.ResourceManager.GetStream("TextFile1.py")).ReadToEnd();
            _controller = new ScriptController(false);
            _controller.OnMessage += (sender, message) =>
                {
                    //Console.WriteLine(message);
                   // Console.WriteLine(String.Format("[{0:HH:MM:ss:fff}][SCRIPT]:{1}", DateTime.Now, message.Trim()));
                    Console.WriteLine(String.Format("{0}", message.Trim()));

                };
            var code = Resources.ResourceManager.GetString("ScriptHeader1");
            dynamic handler = null;
            IScriptContext ctx;
            try
            {

                if (string.IsNullOrEmpty(script))
                {
                    script = code;
                    ctx = _controller.CreateScriptContextFromString(script);
                    ctx.Execute();
                }
                else
                {
                    ctx = _controller.CreateScriptContextFromFile(script);
                    ctx.ExecuteString(code);
                    ctx.Execute();
                }

                handler = ctx.Scope.CreateHandler();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return;
            }

            _mainProcess = new PyProcessContext(ctx, handler,
                _processFactory,
                command,
                CommandArguments,
                workingDirectory,
                _commandParameters);

            _mainProcess.Start();

            ctx.FlushBuffer();
               // Console.ReadKey();
        }
Ejemplo n.º 34
0
 private ScriptController CreateController()
 {
     _controller = new ScriptController(false);
       //  _controller.Engine.Runtime.LoadAssembly(typeof(System.Diagnostics.Process).Assembly);
     _controller.OnMessage += new MessageEvent(_controller_OnMessage);
     return _controller;
 }
Ejemplo n.º 35
0
 private ScriptController BeginProcess(string ProcessName)
 {
     lock (_processControllers)
     {
         if (!_processControllers.TryGetValue(ProcessName, out _controller))
         {
             _controller = CreateController();
             _processControllers[ProcessName] = _controller;
         }
         return _controller;
     }
 }
Ejemplo n.º 36
0
        public object[] RunScript(IRpcContext context, string FileName, List<string> Args)
        {
            GetParams(Args);
            var args = _cmd.ParamsAfterSwitch("args");

            _context = context;
            _fileName = FileName;
            _args = args;
            _controller = BeginProcess(_processName);

            //c.SearchPaths.Add(@"E:\Dev\Source\AndresIPyResource\Scripts");
            var ctx = _controller.CreateScriptContextFromFile(FileName);
            _controller.SetSysArgV(args);

            ctx.Execute();
            return new object[0];
        }
Ejemplo n.º 37
0
        public object[] Eval(IRpcContext context, List<string> Args)
        {
            GetParams(Args);
            _controller = BeginProcess(_processName);
            var ctx = _controller.CreateScriptContextFromString(_code);

            ctx.Execute();

            //code.Run(_controller.Scope);
            return new object[0];
        }
Ejemplo n.º 38
0
        public IScriptContext Compile(string Code)
        {
            try
            {
                _engine = new ScriptController(true);
                _context = _engine.CreateScriptContextFromString(Code, _context);
                foreach (var de in _variables)
                {
                    _context.SetVariable(de.Key, de.Value);
                }

                _engine.OnMessage += new MessageEvent(_engine_OnMessage);
                return _context;
            }
            catch (Exception e)
            {
                LogMessage(e.Message);
                return null;
            }
        }
Ejemplo n.º 39
0
 void CreateScript()
 {
     _engine = new ScriptController(true);
     _context = _engine.CreateScriptContextFromFile(_fullPath);
     _engine.OnMessage += new MessageEvent(_engine_OnMessage);
 }