Exemple #1
0
        private void ParseTemplate(int delayMillSeconds = 100, bool forceExecute = false)
        {
            TaskHelper.Delay("MainWindow+ParseTemplate", () =>
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    LicenseHelper.Instance.Validation();

                    if (ResultTextEditor.AutoCalculate || forceExecute)
                    {
                        var whereText = TextBoxWhere.Text;
                        var template  = TemplateTextEditor.textEditor.Text;

                        var appendNewLine = ResultTextEditor.AppendNewLine;
                        var expandos      = InputTextEditor.GetExpandoObjects(InputTextEditor.EditorMode);

                        ResultTextEditor.AddMessage("Info", "Processing...");

                        // run a task to execute code.
                        Task.Factory.StartNew(() =>
                        {
                            var codeRunner = new CodeRunner();
                            return(codeRunner.ApplyTemplate(expandos, whereText, template, appendNewLine));
                        }).ContinueWith(tt =>
                        {
                            var result = tt.Result;

                            Dispatcher.BeginInvoke(new Action(() =>
                            {
                                ResultTextEditor.textEditor.Text = result.Message;
                                ResultTextEditor.AddMessage("Error", result.Error);
                            }));
                        });
                    }
                }));
            }, delayMillSeconds);
        }