Exemplo n.º 1
0
        private void CodePanel_OnCompilingCode()
        {
            var result = CompilationLanguages.CSharp.CompileCode(Code, Guid.NewGuid().ToString(), CodePanel.References,
                                                                 UserConfig.Instance.AnalyticsDir, UserConfig.Instance.AnalyticsDir);

            CodePanel.ShowCompilationResult(result, _analyticStrategy != null);

            if (result.HasErrors())
            {
                return;
            }

            _scriptType = result.Assembly.GetTypes().FirstOrDefault(t => !t.IsAbstract && t.IsSubclassOf(typeof(Strategy)));
        }
Exemplo n.º 2
0
        public StrategyInfoCodeContent()
        {
            InitializeComponent();

            _timer          = new ResettableTimer(TimeSpan.FromSeconds(1), "Compilation");
            _timer.Elapsed += canProcess => GuiDispatcher.GlobalDispatcher.AddAction(CompileCode);

            var persSvc = ConfigManager.GetService <IPersistableService>();

            CodePanel.References.AddRange(persSvc.GetReferences());
            CodePanel.ReferencesUpdated += () => persSvc.SetReferences(CodePanel.References);

            CodePanel.SavingCode    += SaveCode;
            CodePanel.CompilingCode += CompileCode;
            CodePanel.CodeChanged   += _timer.Activate;

            var cmdSvc = ConfigManager.GetService <IStudioCommandService>();

            cmdSvc.Register <CompileStrategyInfoResultCommand>(this, true, cmd => CodePanel.ShowCompilationResult(cmd.Result, GetStrategiesState()));
            cmdSvc.Register <EditReferencesCommand>(this, true, cmd => CodePanel.EditReferences());
        }