public FileConverter Build()

in src/CTA.WebForms/Factories/FileConverterFactory.cs [55:108]


        public FileConverter Build(FileInfo document)
        {
            // NOTE
            // Existing Type:   FileInfo = System.IO.FileInfo
            // Our New Type:    FileInformation = CTA.WebForms.FileInformationModel.FileInformation

            // Add logic to determine the type of FileInformation
            // object to create, likely using the file type specified
            // in the FileInfo object

            string extension = document.Extension;
            FileConverter fc;
            try
            {
                if (extension.Equals(Constants.CSharpCodeFileExtension))
                {
                    fc = new CodeFileConverter(_sourceProjectPath, document.FullName, _blazorWorkspaceManager,
                        _webFormsProjectAnalyzer, _classConverterFactory, _taskManagerService, _metricsContext);
                }
                else if (extension.Equals(Constants.WebFormsConfigFileExtension))
                {
                    fc = new ConfigFileConverter(_sourceProjectPath, document.FullName, _taskManagerService, _metricsContext);
                }
                else if (extension.Equals(Constants.WebFormsPageMarkupFileExtension)
                         || extension.Equals(Constants.WebFormsControlMarkupFileExtenion)
                         || extension.Equals(Constants.WebFormsMasterPageMarkupFileExtension)
                         || extension.Equals(Constants.WebFormsGlobalMarkupFileExtension))
                {
                    fc = new ViewFileConverter(_sourceProjectPath, document.FullName, _viewImportService,
                        _taskManagerService, _metricsContext);
                }
                else if (extension.Equals(Constants.CSharpProjectFileExtension))
                {
                    fc = new ProjectFileConverter(_sourceProjectPath, document.FullName, _blazorWorkspaceManager,
                        _webFormsProjectAnalyzer, _taskManagerService, _metricsContext);
                }
                else if (StaticResourceExtensions.Contains(extension))
                {
                    fc = new StaticResourceFileConverter(_sourceProjectPath, document.FullName, _hostPageService,
                        _taskManagerService, _metricsContext);
                }
                else
                {
                    fc = new StaticFileConverter(_sourceProjectPath, document.FullName, _taskManagerService, _metricsContext);
                }

                return fc;
            }
            catch (Exception e)
            {
                LogHelper.LogError(e,$"{Rules.Config.Constants.WebFormsErrorTag}Could not build appropriate file converter for {document.FullName}.");
                return null;
            }
        }