public static IEnumerable <TemplateLicense> GetAllLicences(UserSelection userSelection)
 {
     return(Compose(userSelection)
            .SelectMany(s => s.Template.GetLicenses())
            .Distinct(new TemplateLicenseEqualityComparer())
            .ToList());
 }
示例#2
0
        internal void ShowError(Exception ex, UserSelection userSelection = null)
        {
            AppHealth.Current.Error.TrackAsync(ex.ToString()).FireAndForget();
            AppHealth.Current.Exception.TrackAsync(ex, userSelection?.ToString()).FireAndForget();

            var error = new ErrorDialog(ex);

            GenContext.ToolBox.Shell.ShowModal(error);
        }
        private static void AddProject(UserSelection userSelection, List <GenInfo> genQueue)
        {
            var projectTemplate = GetProjectTemplate(userSelection.ProjectType, userSelection.Framework);
            var genProject      = CreateGenInfo(GenContext.Current.ProjectName, projectTemplate, genQueue);

            genProject.Parameters.Add(GenParams.Username, Environment.UserName);
            genProject.Parameters.Add(GenParams.WizardVersion, GenContext.ToolBox.WizardVersion);
            genProject.Parameters.Add(GenParams.TemplatesVersion, GenContext.ToolBox.TemplatesVersion);
        }
        public async Task UnsafeGenerateNewItemAsync(TemplateType templateType, UserSelection userSelection)
        {
            var genItems = GenComposer.ComposeNewItem(userSelection).ToList();
            var chrono   = Stopwatch.StartNew();

            var genResults = await GenerateItemsAsync(genItems, true);

            chrono.Stop();

            TrackTelemery(templateType, genItems, genResults, chrono.Elapsed.TotalSeconds, userSelection.ProjectType, userSelection.Framework, userSelection.Platform);
        }
        public async Task UnsafeGenerateProjectAsync(UserSelection userSelection)
        {
            var genItems = GenComposer.Compose(userSelection).ToList();
            var chrono   = Stopwatch.StartNew();

            var genResults = await GenerateItemsAsync(genItems);

            chrono.Stop();

            TrackTelemery(genItems, genResults, chrono.Elapsed.TotalSeconds, userSelection.ProjectType, userSelection.Framework, userSelection.Language);
        }
 public void FinishGeneration(UserSelection userSelection)
 {
     try
     {
         UnsafeFinishGeneration(userSelection);
     }
     catch (Exception ex)
     {
         ShowError(ex, userSelection);
         GenContext.ToolBox.Shell.CancelWizard(false);
     }
 }
        public async Task GenerateNewItemAsync(TemplateType templateType, UserSelection userSelection)
        {
            try
            {
                await UnsafeGenerateNewItemAsync(templateType, userSelection);
            }
            catch (Exception ex)
            {
                ShowError(ex, userSelection);

                GenContext.ToolBox.Shell.CancelWizard(false);
            }
        }
        public void UnsafeFinishGeneration(UserSelection userSelection)
        {
            var compareResult = CompareTempGenerationWithProject();

            if (userSelection.ItemGenerationType == ItemGenerationType.GenerateAndMerge)
            {
                // BackupProjectFiles
                ExecuteSyncGenerationPostActions(compareResult);
            }
            else
            {
                ExecuteOutputGenerationPostActions(compareResult);
            }
        }
        public async Task GenerateProjectAsync(UserSelection userSelection)
        {
            try
            {
                await UnsafeGenerateProjectAsync(userSelection);
            }
            catch (Exception ex)
            {
                GenContext.ToolBox.Shell.CloseSolution();

                ShowError(ex, userSelection);

                GenContext.ToolBox.Shell.CancelWizard(false);
            }
        }
示例#10
0
        public static IEnumerable <GenInfo> ComposeNewItem(UserSelection userSelection)
        {
            var genQueue = new List <GenInfo>();

            if (string.IsNullOrEmpty(userSelection.ProjectType) || string.IsNullOrEmpty(userSelection.Framework))
            {
                return(genQueue);
            }

            AddTemplates(userSelection.Pages, genQueue, userSelection);
            AddTemplates(userSelection.Features, genQueue, userSelection);

            AddCompositionTemplates(genQueue, userSelection);

            return(genQueue);
        }
        public void UnsafeFinishGeneration(UserSelection userSelection)
        {
            // Put outputpath back to solution level
            GenContext.Current.OutputPath = GenContext.Current.TempGenerationPath;

            var compareResult = CompareTempGenerationWithProject();

            if (userSelection.ItemGenerationType == ItemGenerationType.GenerateAndMerge)
            {
                // BackupProjectFiles
                compareResult.SyncGeneration = true;
                ExecuteSyncGenerationPostActions(compareResult);
            }
            else
            {
                compareResult.SyncGeneration = false;
                ExecuteOutputGenerationPostActions(compareResult);
            }
        }
示例#12
0
        public static async Task UnsafeGenerateAsync(UserSelection userSelection)
        {
            var genItems   = GenComposer.Compose(userSelection).ToList();
            var chrono     = Stopwatch.StartNew();
            var genResults = new Dictionary <string, TemplateCreationResult>();

            foreach (var genInfo in genItems)
            {
                if (genInfo.Template == null)
                {
                    continue;
                }

                var statusText = GetStatusText(genInfo);

                if (!string.IsNullOrEmpty(statusText))
                {
                    GenContext.ToolBox.Shell.ShowStatusBarMessage(statusText);
                }

                AppHealth.Current.Info.TrackAsync($"Generating the template {genInfo.Template.Name} to {GenContext.Current.OutputPath}.").FireAndForget();

                var result = await CodeGen.Instance.Creator.InstantiateAsync(genInfo.Template, genInfo.Name, null, GenContext.Current.OutputPath, genInfo.Parameters, false, false, null);

                genResults.Add($"{genInfo.Template.Identity}_{genInfo.Name}", result);

                if (result.Status != CreationResultStatus.Success)
                {
                    throw new GenException(genInfo.Name, genInfo.Template.Name, result.Message);
                }

                ExecutePostActions(genInfo, result);
            }

            ExecuteGlobalPostActions(genItems);

            chrono.Stop();

            TrackTelemery(genItems, genResults, chrono.Elapsed.TotalSeconds, userSelection.ProjectType, userSelection.Framework);
        }