public async Task Execute() { var loggers = new List <ILog> { new ConsoleLog() }; if (!string.IsNullOrEmpty(LogTo)) { loggers.Add(new FileLog(LogTo)); } var engine = TemplatingEngine.Init(loggers.ToArray()); var projectDirectory = TemplatePaths .Select(x => Path.Combine(x, $"projects\\{Template}")) .FirstOrDefault(Directory.Exists); if (string.IsNullOrEmpty(projectDirectory)) { projectDirectory = TemplatePaths .Select(x => Path.Combine(x, "projects\\base")) .FirstOrDefault(Directory.Exists); } var substitutions = new ReadOnlyDictionary <string, string>(new Dictionary <string, string> { { "PROJECT_NAME", Name }, { "SOLUTION", Solution }, { "PROJECT_GUID", ProjectGuid } }); if (!string.IsNullOrEmpty(projectDirectory)) { await engine.RunTemplate( new ProjectTemplateType(Name, Solution, Location, Path.Combine(Location, $"src\\{Name}"), ProjectGuid, substitutions), projectDirectory).ConfigureAwait(false); await new AlterCommand { Name = Name, Solution = Solution, Location = Location, TemplatePaths = TemplatePaths, Template = Template, LogTo = LogTo }.Execute().ConfigureAwait(false); } }
private void LoadTemplatesFromServer() { IEnumerable <CasparServerCommands.TlsCommand.TemplatePath> TemplatePaths; if (PluginInterfaces.PublicProviders.CasparServer.IsConnected) { TemplatePaths = CasparServerCommands.TlsCommand.ParseResponse(PluginInterfaces.PublicProviders.CasparServer.ExecuteCommand(new CasparServerCommands.TlsCommand())); } else { TemplatePaths = new List <CasparServerCommands.TlsCommand.TemplatePath>() { new CasparServerCommands.TlsCommand.TemplatePath("1/1.1/1.1.1/FILE_1.1.1", 1, "20141234"), new CasparServerCommands.TlsCommand.TemplatePath("1/1.1/1.1.2/FILE_1.1.2", 2, "20141234"), new CasparServerCommands.TlsCommand.TemplatePath("1/1.2/1.2.1/FILE_1.2.1", 3, "20141234"), new CasparServerCommands.TlsCommand.TemplatePath("1/1.2/1.2.2/FILE_1.2.2", 4, "20141234"), new CasparServerCommands.TlsCommand.TemplatePath("2/2.1/2.1.1/FILE_2.1.1", 5, "20141234"), new CasparServerCommands.TlsCommand.TemplatePath("2/2.1/2.1.2/FILE_2.1.2", 6, "20141234"), new CasparServerCommands.TlsCommand.TemplatePath("2/2.2/2.2.1/FILE_2.2.1", 7, "20141234"), new CasparServerCommands.TlsCommand.TemplatePath("2/2.2/2.2.2/FILE_2.2.2", 8, "20141234") }; return; } var FilteredPaths = _CurrentFilter == null ? TemplatePaths : TemplatePaths.Where(i => i.Directory.StartsWith(_CurrentFilter, StringComparison.InvariantCultureIgnoreCase)); var PreviouslyLoadedTemplate = ViewModel.TemplateIsLoaded ? ViewModel.SelectedTennisTemplate : null; var PreviouslySelectedTemplate = ViewModel.SelectedTennisTemplate as ServerStoredTennisTemplate; var NewTemplates = FilteredPaths.Select(i => new ServerStoredTennisTemplate(i)); if (PreviouslyLoadedTemplate != null && PreviouslyLoadedTemplate is ServerStoredTennisTemplate) { var Matches = NewTemplates.Where(i => i.Path.FullPath == ((ServerStoredTennisTemplate)PreviouslyLoadedTemplate).Path.FullPath); if (Matches.Any()) { PreviouslyLoadedTemplate = Matches.First(); } } ViewModel.AvailableTennisTemplates = PreviouslyLoadedTemplate == null || NewTemplates.Contains(PreviouslyLoadedTemplate) ? NewTemplates : NewTemplates.Prepend(PreviouslyLoadedTemplate); if (PreviouslyLoadedTemplate != null) { ViewModel.SelectedTennisTemplate = PreviouslyLoadedTemplate; } else if (PreviouslySelectedTemplate != null) { ViewModel.SelectedTennisTemplate = NewTemplates.SingleOrDefault(i => i.Path.FullPath == PreviouslySelectedTemplate.Path.FullPath); } }
public async Task Execute() { var loggers = new List <ILog> { new ConsoleLog() }; if (!string.IsNullOrEmpty(LogTo)) { loggers.Add(new FileLog(LogTo)); } var engine = TemplatingEngine.Init(loggers.ToArray()); var alterationDirectories = TemplatePaths .Select(x => Path.Combine(x, "alterations\\base")) .Where(Directory.Exists) .ToList(); alterationDirectories.AddRange(TemplatePaths .Select(x => Path.Combine(x, $"alterations\\{Template}")) .Where(Directory.Exists)); var substitutions = new ReadOnlyDictionary <string, string>(new Dictionary <string, string> { { "PROJECT_NAME", Name }, { "SOLUTION", Solution } }); foreach (var alterationDirectory in alterationDirectories) { await engine.RunTemplate( new AlterationTemplateType(Name, Location, Path.Combine(Location, $"src\\{Name}"), substitutions), alterationDirectory).ConfigureAwait(false); } }