コード例 #1
0
        public override DocumentResults?ExecuteQuery(String input, String text)
        {
            try
            {
                context = new CompilationContext(workspace, document.WithText(SourceText.From(text)));

                var csharpBootStrapper = BootstrapperBuilder.Create(bootstrapper)
                                         .WithExecutor(new StandardExecutorWithContext(bootstrapper.RunnableManager, context))
                                         .Build();

                // var root = this.compiler.Parse(text);
                var response = input; // + " | convert-to-string";
                var controlFlowDescriptor = csharpBootStrapper.Compiler.Parse(response);
                var controlFlow           = csharpBootStrapper.ControlFlowFactory.Create(controlFlowDescriptor);
                var result = controlFlow.Execute(new[] { context.CurrentDocument.GetSyntaxRootAsync().Result }) as IEnumerable <Object>;

                var source = context.DocumentEditor.GetChangedDocument().GetSyntaxRootAsync().Result;

                var documentResults = new DocumentResults()
                {
                    Source  = source.ToFullString(),
                    Results = String.Join(Environment.NewLine, result.OfType <SyntaxNode>().Select(node => node.ToFullString()))
                };

                return(documentResults);
            }
            catch (Exception exception)
            {
                Console.WriteLine($"Error message: {exception.Message}");
                Console.WriteLine("Stacktrace: ");
                Console.WriteLine(exception.StackTrace);

                return(null);
            }
        }
コード例 #2
0
 static int Main(string[] args)
 => BootstrapperBuilder.Create <BomToolBootstrapper>()
 .DetectQtRuntime()
 .EnableLogging(true)
 .SetStyle("Material")
 // set main ui qml file
 .SetMainQml(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Views", "Main.qml"))
 .Build()
 .Launch(args);
コード例 #3
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            var bootstrapperBuilder = new BootstrapperBuilder();
            var bootstrapper        = bootstrapperBuilder.Build();

            bootstrapper.OpenNewWindow(
                new StartVM(),
                vm => vm.WindowTitle = string.Empty,
                null,
                null,
                nav => nav.ViewNavigator.ShowDialog("Вы точно хотите выйти из программы?", ModalIcon.Question, "Выход", "Выйти", "Отмена"));
        }
コード例 #4
0
        public override bool Execute()
        {
            BootstrapperBuilder builder = new BootstrapperBuilder {
                Validate = this.Validate,
                Path     = this.Path
            };
            ProductCollection products = builder.Products;
            BuildSettings     settings = new BuildSettings {
                ApplicationFile = this.ApplicationFile,
                ApplicationName = this.ApplicationName,
                ApplicationRequiresElevation = this.ApplicationRequiresElevation,
                ApplicationUrl     = this.ApplicationUrl,
                ComponentsLocation = this.ConvertStringToComponentsLocation(this.ComponentsLocation),
                ComponentsUrl      = this.ComponentsUrl,
                CopyComponents     = this.CopyComponents,
                Culture            = this.culture,
                FallbackCulture    = this.fallbackCulture,
                OutputPath         = this.OutputPath,
                SupportUrl         = this.SupportUrl
            };

            if (this.BootstrapperItems != null)
            {
                Hashtable hashtable = new Hashtable(StringComparer.OrdinalIgnoreCase);
                foreach (ITaskItem item in this.BootstrapperItems)
                {
                    string metadata = item.GetMetadata("Install");
                    if (string.IsNullOrEmpty(metadata) || ConversionUtilities.ConvertStringToBool(metadata))
                    {
                        if (!hashtable.Contains(item.ItemSpec))
                        {
                            hashtable.Add(item.ItemSpec, item);
                        }
                        else
                        {
                            base.Log.LogWarningWithCodeFromResources("GenerateBootstrapper.DuplicateItems", new object[] { item.ItemSpec });
                        }
                    }
                }
                foreach (Product product in products)
                {
                    if (hashtable.Contains(product.ProductCode))
                    {
                        settings.ProductBuilders.Add(product.ProductBuilder);
                        hashtable.Remove(product.ProductCode);
                    }
                }
                foreach (ITaskItem item2 in hashtable.Values)
                {
                    base.Log.LogWarningWithCodeFromResources("GenerateBootstrapper.ProductNotFound", new object[] { item2.ItemSpec, builder.Path });
                }
            }
            BuildResults results = builder.Build(settings);

            BuildMessage[] messages = results.Messages;
            if (messages != null)
            {
                foreach (BuildMessage message in messages)
                {
                    if (message.Severity == BuildMessageSeverity.Error)
                    {
                        base.Log.LogError(null, message.HelpCode, message.HelpKeyword, null, 0, 0, 0, 0, message.Message, new object[0]);
                    }
                    else if (message.Severity == BuildMessageSeverity.Warning)
                    {
                        base.Log.LogWarning(null, message.HelpCode, message.HelpKeyword, null, 0, 0, 0, 0, message.Message, new object[0]);
                    }
                }
            }
            this.BootstrapperKeyFile        = results.KeyFile;
            this.BootstrapperComponentFiles = results.ComponentFiles;
            return(results.Succeeded);
        }
コード例 #5
0
        /// <summary>
        /// Generate the bootstrapper.
        /// </summary>
        /// <returns> Return true on success, false on failure.</returns>
        public override bool Execute()
        {
            if (_path == null)
            {
                _path = Util.GetDefaultPath(_visualStudioVersion);
            }

            BootstrapperBuilder bootstrapperBuilder = new BootstrapperBuilder();

            bootstrapperBuilder.Validate = this.Validate;
            bootstrapperBuilder.Path     = this.Path;

            ProductCollection products = bootstrapperBuilder.Products;

            BuildSettings settings = new BuildSettings();

            settings.ApplicationFile = ApplicationFile;
            settings.ApplicationName = ApplicationName;
            settings.ApplicationRequiresElevation = ApplicationRequiresElevation;
            settings.ApplicationUrl     = ApplicationUrl;
            settings.ComponentsLocation = ConvertStringToComponentsLocation(this.ComponentsLocation);
            settings.ComponentsUrl      = ComponentsUrl;
            settings.CopyComponents     = CopyComponents;
            settings.Culture            = _culture;
            settings.FallbackCulture    = _fallbackCulture;
            settings.OutputPath         = this.OutputPath;
            settings.SupportUrl         = this.SupportUrl;

            if (String.IsNullOrEmpty(settings.Culture) || settings.Culture == "*")
            {
                settings.Culture = settings.FallbackCulture;
            }

            if (this.BootstrapperItems != null)
            {
                // The bootstrapper items may not be in the correct order, because XMake saves
                // items in alphabetical order.  So we will attempt to put items into the correct
                // order, according to the Products order in the search.  To do this, we add all
                // the items we are told to build into a hashtable, then go through our products
                // in order, looking to see if the item is built.  If it is, remove the item from
                // the hashtable.  All remaining items in the table can not be built, so errors
                // will be issued.
                Hashtable items = new Hashtable(StringComparer.OrdinalIgnoreCase);

                foreach (ITaskItem bootstrapperItem in this.BootstrapperItems)
                {
                    string installAttribute = bootstrapperItem.GetMetadata("Install");
                    if (String.IsNullOrEmpty(installAttribute) || Shared.ConversionUtilities.ConvertStringToBool(installAttribute))
                    {
                        if (!items.Contains(bootstrapperItem.ItemSpec))
                        {
                            items.Add(bootstrapperItem.ItemSpec, bootstrapperItem);
                        }
                        else
                        {
                            Log.LogWarningWithCodeFromResources("GenerateBootstrapper.DuplicateItems", bootstrapperItem.ItemSpec);
                        }
                    }
                }

                foreach (Product product in products)
                {
                    if (items.Contains(product.ProductCode))
                    {
                        settings.ProductBuilders.Add(product.ProductBuilder);
                        items.Remove(product.ProductCode);
                    }
                }

                foreach (ITaskItem bootstrapperItem in items.Values)
                {
                    Log.LogWarningWithCodeFromResources("GenerateBootstrapper.ProductNotFound", bootstrapperItem.ItemSpec, bootstrapperBuilder.Path);
                }
            }

            BuildResults results = bootstrapperBuilder.Build(settings);

            BuildMessage[] messages = results.Messages;

            if (messages != null)
            {
                foreach (BuildMessage message in messages)
                {
                    if (message.Severity == BuildMessageSeverity.Error)
                    {
                        Log.LogError(null, message.HelpCode, message.HelpKeyword, null, 0, 0, 0, 0, message.Message);
                    }
                    else if (message.Severity == BuildMessageSeverity.Warning)
                    {
                        Log.LogWarning(null, message.HelpCode, message.HelpKeyword, null, 0, 0, 0, 0, message.Message);
                    }
                }
            }

            this.BootstrapperKeyFile        = results.KeyFile;
            this.BootstrapperComponentFiles = results.ComponentFiles;

            return(results.Succeeded);
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: gitter-badger/MathClasses
        private static void Main()
        {
            var bootstrapperBuilder = new BootstrapperBuilder();

            bootstrapperBuilder.Build();
        }
コード例 #7
0
 internal void Bind(BootstrapperBuilder builder) => Builder = builder;
コード例 #8
0
        protected override void OnStartup(StartupEventArgs e)
        {
            var bootstrapper = new BootstrapperBuilder().Build();

            bootstrapper.OpenNewWindow(new MainWindow(), new CountDownVM(), null, null, null, _ => Timer.Properties.Settings.Default.Save());
        }