コード例 #1
0
ファイル: SynchronizationState.cs プロジェクト: 424f/lebowski
        /// <inheritdoc/>
        /// <remarks>
        /// Handles the following event types: CloseSessionMessage, ChatMessage, 
        /// ExecutionResultMessage.
        /// </remarks>
        protected override void ApplicationConnectionReceived(object sender, ReceivedEventArgs e)
        {
            if (e.Message is CloseSessionMessage)
            {
                session.Reset();
            }
            else if (e.Message is ChatMessage)
            {
                session.OnReceiveChatMessage(new ReceiveChatMessageEventArgs((ChatMessage)e.Message));
            }
            else if (e.Message is ExecutionResultMessage)
            {
                ExecutionResultMessage erm = (ExecutionResultMessage)e.Message;

                ExecutionResult result = new ExecutionResult();

                session.OnStartedExecution(new StartedExecutionEventArgs((int)session.ApplicationConnection.Tag, result));

                result.OnExecutionChanged(new ExecutionChangedEventArgs(erm.StandardOut));
                result.OnFinishedExecution(new FinishedExecutionEventArgs(0, erm.StandardOut));
            }
            else
            {
                Logger.WarnFormat("Received unsupported message on application connection: {0}", e.Message.GetType().Name);
                base.ApplicationConnectionReceived(sender, e);
            }
        }
コード例 #2
0
ファイル: PythonFileTypeTest.cs プロジェクト: 424f/lebowski
 public void SetUp()
 {
     result = new ExecutionResult();
     result.ExecutionChanged += ResultExecutionChanged;
     result.FinishedExecution += ResultFinishedExecution;
     finishedExecution = false;
     stdout = "";
 }
コード例 #3
0
ファイル: ExecutionViewForm.cs プロジェクト: 424f/lebowski
 /// <summary>
 /// Initializes a new instance of the ExecutionViewForm with an 
 /// ExecutionResult.
 /// </summary>
 /// <param name="executionResult"></param>
 public ExecutionViewForm(ExecutionResult executionResult)
 {
     InitializeComponent();
     this.executionResult = executionResult;
     executionResult.ExecutionChanged += ExecutionResultChanged;
 }
コード例 #4
0
ファイル: SessionContext.cs プロジェクト: 424f/lebowski
        /// <summary>
        /// Executes the document associated with the session.
        /// </summary>
        public void Execute()
        {
            ExecutionResult result = new ExecutionResult();

            OnStartedExecution(new StartedExecutionEventArgs(SiteId, result));

            FileType.Execute(Context.Data, result);

            // When execution is finished, propagate result to other users
            result.FinishedExecution += delegate(object o, FinishedExecutionEventArgs fe)
            {
                if (State == SessionStates.Connected)
                {
                    ApplicationConnection.Send(new Messaging.ExecutionResultMessage(fe.ReturnCode, fe.StandardOut));
                }
            };
        }
コード例 #5
0
ファイル: PythonFileTypeTest.cs プロジェクト: 424f/lebowski
 public void TearDown()
 {
     result.ExecutionChanged -= ResultExecutionChanged;
     result.FinishedExecution -= ResultFinishedExecution;
     result = null;
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the StartedExecutionEventArgs class.
 /// </summary>
 /// <param name="siteId">See <see cref="SiteId">SiteId</see>.</param>
 /// <param name="executionResult">See <see cref="ExecutionResult">ExecutionResult</see>.</param>
 public StartedExecutionEventArgs(int siteId, ExecutionResult executionResult)
 {
     ExecutionResult = executionResult;
     SiteId = siteId;
 }
コード例 #7
0
ファイル: PythonFileType.cs プロジェクト: 424f/lebowski
 /// <summary>
 /// Spawns a new thread that performs the execution of the content.
 /// </summary>
 /// <param name="content">Source code to be executed.</param>
 /// <param name="result">ExecutionResult instance that fires events according to the execution state.</param>
 public void Execute(string content, ExecutionResult result)
 {
     ThreadStart ts = new ThreadStart((Action) delegate { DoExecute(content, result); });
     Thread t = new Thread(ts);
     t.Name = "Python execution thread";
     t.Start();
 }
コード例 #8
0
ファイル: PythonFileType.cs プロジェクト: 424f/lebowski
 private void DoExecute(string content, ExecutionResult result)
 {
     var writer = new PythonStringWriter();
     string standardOut = "";
     writer.Write += delegate(object sender, WriteEventArgs e)
     {
         standardOut += e.Text.Replace("\n", Environment.NewLine);
         result.OnExecutionChanged(new ExecutionChangedEventArgs(e.Text.Replace("\n", Environment.NewLine)));
     };
     interpreter.ExecuteCode(content, writer);
     result.OnFinishedExecution(new FinishedExecutionEventArgs(0, standardOut));
 }
コード例 #9
0
ファイル: TextFileType.cs プロジェクト: 424f/lebowski
 /// <inheritdoc/>
 public void Execute(string content, ExecutionResult stdout)
 {
 }