public ViewFileConverter( string sourceProjectPath, string fullPath, ViewImportService viewImportService, TaskManagerService taskManagerService, WebFormMetricContext metricsContext) : base(sourceProjectPath, fullPath, taskManagerService) { _viewImportService = viewImportService; _controlActions = new List <ControlConversionAction>(); _metricsContext = metricsContext; }
private void InitializeServices() { _taskManager = new TaskManagerService(); _lifecycleManager = new LifecycleManagerService(); _viewImportService = new ViewImportService(); _programCsService = new ProgramCsService(); _appRazorService = new AppRazorService(); _hostPageService = new HostPageService(); _blazorWorkspaceManager = new WorkspaceManagerService(); // By convention, we expect the root namespace to share a name with the project // root folder, we normalize the folder name before using it in case the folder name // is not a valid identifier var rootNamespace = Utilities.NormalizeNamespaceIdentifier(_analyzerResult.ProjectResult.ProjectName); _programCsService.ProgramCsNamespace = rootNamespace; _hostPageService.HostNamespace = rootNamespace; _blazorWorkspaceManager.CreateSolutionFile(); }
public FileConverterFactory( string sourceProjectPath, WorkspaceManagerService blazorWorkspaceManager, ProjectAnalyzer webFormsProjectAnalyzer, ViewImportService viewImportService, ClassConverterFactory classConverterFactory, HostPageService hostPageService, TaskManagerService taskManagerService, WebFormMetricContext metricsContext) { _sourceProjectPath = sourceProjectPath; _blazorWorkspaceManager = blazorWorkspaceManager; _webFormsProjectAnalyzer = webFormsProjectAnalyzer; _viewImportService = viewImportService; _classConverterFactory = classConverterFactory; _hostPageService = hostPageService; _taskManagerService = taskManagerService; _metricsContext = metricsContext; }
public string ConvertDirective(string directiveName, string directiveString, string originalFilePath, string projectName, ViewImportService viewImportService) { // TODO: We want to make sure that certain directives only occur once (i.e. layout, // inherits, etc.) Need to find a better way to detect and deal with those or perhaps // just leave it up the the developer given that detecting which layout or base class // to choose is difficult var migrationResults = GetMigratedAttributes(directiveString, directiveName, projectName); // Want to ensure that the general directive conversion stays at the front if it exists migrationResults = GetMigratedDirectives(directiveName, originalFilePath).Concat(migrationResults); // Remove any using directive results and send them to the viewImports service migrationResults = migrationResults.Where(migrationResult => { if (migrationResult.MigrationResultType == DirectiveMigrationResultType.UsingDirective) { viewImportService.AddViewImport(migrationResult.Content); return(false); } return(true); }); return(string.Join(Environment.NewLine, migrationResults.Select(migrationResult => migrationResult.Content))); }
public static string ConvertEmbeddedCode(string htmlString, string originalFilePath, ViewImportService viewImportService) { htmlString = EmbeddedCodeReplacers.ReplaceOneWayDataBinds(htmlString); htmlString = EmbeddedCodeReplacers.ReplaceRawExprs(htmlString); htmlString = EmbeddedCodeReplacers.ReplaceHTMLEncodedExprs(htmlString); htmlString = EmbeddedCodeReplacers.ReplaceAspExprs(htmlString); htmlString = EmbeddedCodeReplacers.ReplaceAspComments(htmlString); htmlString = EmbeddedCodeReplacers.ReplaceEmbeddedCodeBlocks(htmlString); return(htmlString); }
public static string ReplaceDirectives(string htmlString, string originalFilePath, string projectName, ViewImportService viewImportService, WebFormMetricContext metricContext) { return(DirectiveRegex.Replace(htmlString, match => ConstructBlazorDirectives( match.Groups[EmbeddedExpressionRegexGroupName].Value, originalFilePath, projectName, viewImportService, metricContext))); }
public static string ConstructBlazorDirectives(string content, string originalFilePath, string projectName, ViewImportService viewImportService, WebFormMetricContext metricContext) { var directiveName = DirectiveNameRegex.Match(content).Groups[DirectiveNameRegexGroupName].Value; var directiveConverter = SupportedControls.DirectiveRulesMap.ContainsKey(directiveName) ? SupportedControls.DirectiveRulesMap[directiveName] : SupportedControls.DefaultDirectiveConverter; metricContext.CollectActionMetrics(WebFormsActionType.DirectiveConversion, directiveName + "DirectiveConverter"); return(directiveConverter.ConvertDirective(directiveName, content.Trim(), originalFilePath, projectName, viewImportService)); }
public void SetUp() { _viewImportService = new ViewImportService(); }