alielie
2026-09-10 9ec80cafc23f5ee3278cacce3c9f86f4087b435a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
 
namespace DynamicExpressoWebShell.Services
{
    public class WebShell
    {
        readonly DynamicExpresso.Interpreter _interpreter;
        readonly CommandsHistory _commandsHistory;
 
        public WebShell()
        {
            _interpreter = new DynamicExpresso.Interpreter();
            _commandsHistory = new CommandsHistory();
 
            _interpreter.SetVariable("Commands", _commandsHistory);
        }
 
        public object Eval(string expression)
        {
            if (expression != null && expression.Length > 200)
                throw new Exception("Live demo doesn't support expression with more than 200 characters.");
 
            _commandsHistory.HandleCommandExecuted(new CommandEvent(expression));
 
            var result = _interpreter.Eval(expression);
 
            return result;
        }
 
        public CommandsHistory CommandsHistory
        {
            get;
            private set;
        }
    }
}