aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Scripting/Tango.Scripting.Basic/Script.cs
blob: c465292cbd16403cbf1638f19598151b63148629 (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core;
using Tango.Scripting.Core;

namespace Tango.Scripting.Basic
{
    public class Script : ExtendedObject, IScriptSource
    {
        private String _name;
        public String Name
        {
            get { return _name; }
            set { _name = value; RaisePropertyChangedAuto(); }
        }

        public bool IsEntryPoint { get; set; }

        private String _code;
        public String Code
        {
            get { return _code; }
            set
            {
                if (_code != null && _code != value)
                {
                    IsChanged = true;
                }

                _code = value;
                RaisePropertyChangedAuto();
            }
        }

        private bool _isChanged;
        [JsonIgnore]
        public bool IsChanged
        {
            get { return _isChanged; }
            set { _isChanged = value; RaisePropertyChangedAuto(); }
        }

        private bool _isSelected;
        [JsonIgnore]
        public bool IsSelected
        {
            get { return _isSelected; }
            set { _isSelected = value; RaisePropertyChangedAuto(); }
        }

        [JsonIgnore]
        public int LoadCount { get; internal set; }
        [JsonIgnore]
        public int LoadCharCount { get; set; }

        public static Script New(String file)
        {
            return new Script()
            {
                Name = Path.GetFileName(file),
                Code = System.IO.File.ReadAllText(file),
            };
        }

        public static Script New(String name, String code, bool isEntryPoint = false)
        {
            return new Script()
            {
                Name = name,
                Code = code,
                IsEntryPoint = isEntryPoint,
            };
        }
    }
}