Exemple #1
0
        public ScriptProcess()
        {
            DesignBackColor = Color.Red;
            Options         = new ScriptHelper.ScriptOptions()
            {
                Inherited = new Type[] { typeof(IScriptProcess) }
            };

            Options.IncludeFiles  = Options.IncludeFiles.Concat(new string[] { "@Laster.Process.dll", "@Laster.Core.dll" }).ToArray();
            Options.IncludeUsings = Options.IncludeUsings.Concat(new string[] { "Laster.Process", "Laster.Core.Interfaces", "Laster.Core.Enums", "Laster.Core.Data" }).ToArray();

            Code = @"public override IData ProcessData(IDataProcess sender, IData data, EEnumerableDataState state)
{
    return data;
}";
        }
Exemple #2
0
        public FScriptForm(ScriptHelper.ScriptOptions opt) : base()
        {
            InitializeComponent();

            _Options               = opt;
            tEdit.Lexer            = Lexer.Cpp;
            tEdit.Margins[0].Type  = MarginType.Number;
            tEdit.Margins[0].Width = 35;

            tEdit.SetSelectionBackColor(true, Color.FromArgb(200, 227, 255));

            tEdit.StyleResetDefault();
            tEdit.Styles[Style.Default].Font = "Consolas";
            tEdit.Styles[Style.Default].Size = 10;
            tEdit.StyleClearAll();

            // Configure the CPP (C#) lexer styles
            tEdit.Styles[Style.Cpp.Default].ForeColor        = Color.Silver;
            tEdit.Styles[Style.Cpp.Comment].ForeColor        = Color.FromArgb(0, 128, 0);     // Green
            tEdit.Styles[Style.Cpp.CommentLine].ForeColor    = Color.FromArgb(0, 128, 0);     // Green
            tEdit.Styles[Style.Cpp.CommentLineDoc].ForeColor = Color.FromArgb(128, 128, 128); // Gray
            tEdit.Styles[Style.Cpp.Number].ForeColor         = Color.Olive;
            tEdit.Styles[Style.Cpp.Word].ForeColor           = Color.Blue;
            tEdit.Styles[Style.Cpp.Word2].ForeColor          = Color.Blue;
            tEdit.Styles[Style.Cpp.String].ForeColor         = Color.FromArgb(163, 21, 21); // Red
            tEdit.Styles[Style.Cpp.Character].ForeColor      = Color.FromArgb(163, 21, 21); // Red
            tEdit.Styles[Style.Cpp.Verbatim].ForeColor       = Color.FromArgb(163, 21, 21); // Red
            tEdit.Styles[Style.Cpp.StringEol].BackColor      = Color.Pink;
            tEdit.Styles[Style.Cpp.Operator].ForeColor       = Color.Purple;
            tEdit.Styles[Style.Cpp.Preprocessor].ForeColor   = Color.Maroon;
            tEdit.Styles[Style.Cpp.GlobalClass].ForeColor    = Color.FromArgb(43, 145, 175);

            // Set the keywords
            tEdit.SetKeywords(0, "dynamic abstract as base break case catch checked continue default delegate do else event explicit extern false finally fixed for foreach goto if implicit in interface internal is lock namespace new null object operator out override params private protected public readonly ref return sealed sizeof stackalloc switch this throw true try typeof unchecked unsafe using virtual while get set");
            tEdit.SetKeywords(1, "bool byte char class const decimal double enum float int long sbyte short static string struct uint ulong ushort void Decimal Double DateTime TimeSpan Type");

            // Load from assemblies defined Types
            List <string> add = new List <string>();

            foreach (string file in _Options.IncludeFiles)
            {
                bool   isGac;
                string f = ScriptHelper.ScriptOptions.GetFile(file, out isGac);

                try
                {
                    Assembly asm   = null;
                    Type     tAttr = typeof(Attribute);

                    if (!isGac)
                    {
                        asm = Assembly.LoadFrom(f);
                    }
                    else
                    {
                        asm = Assembly.LoadWithPartialName(Path.GetFileNameWithoutExtension(f));
                    }

                    if (asm != null)
                    {
                        foreach (Type t in asm.GetExportedTypes())
                        {
                            if (!t.IsPublic)
                            {
                                continue;
                            }

                            foreach (string nm in _Options.IncludeUsings)
                            {
                                if (t.Namespace != nm)
                                {
                                    continue;
                                }

                                string nam = t.Name;
                                if (t.IsGenericType)
                                {
                                    int ix = nam.IndexOf("`");
                                    if (ix != -1)
                                    {
                                        nam = nam.Substring(0, ix);
                                    }
                                }

                                if (!add.Contains(nam))
                                {
                                    add.Add(nam);
                                }

                                if (tAttr.IsAssignableFrom(t))
                                {
                                    if (nam.EndsWith("Attribute"))
                                    {
                                        nam = nam.Remove(nam.Length - 9, 9);
                                        if (!add.Contains(nam))
                                        {
                                            add.Add(nam);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch { }
            }

            DefinedClasses = string.Join(" ", add);
            tEdit.SetKeywords(3, DefinedClasses);
            tEdit.Invalidate();
        }