Ejemplo n.º 1
0
        public void GenerateModelInterfaceFromCsvFile(string genInterfaceName, string fileGeneratedNameWithExt, string csvFilePath, string destinationfullDirectoryPath)
        {
            //string pathCSVFile = _DataServiceForCsvFile.Reader_GitHubUser_Datasets.FilePath_csv_countryCodes;
            string[] headers = BasicHelpers.GetCsvHeaderNames(csvFilePath);

            //Create fields
            string interfaceFields = string.Empty;

            for (int i = 0; i < headers.Length; i++)
            {
                //Filter non alphanumeric characters
                string filteredString_toAlphanumeric = BasicHelpers._ReplcaeNonAlphanumeric(headers[i]);
                //Lowercase all the string
                filteredString_toAlphanumeric = filteredString_toAlphanumeric.ToLowerInvariant();
                //Uppercase only first letter of the string
                filteredString_toAlphanumeric = BasicHelpers.FirstCharToUpper(filteredString_toAlphanumeric);

                interfaceFields = interfaceFields + $@"
    string {filteredString_toAlphanumeric} {{ get; set; }}";
            }



            string modelAutoGenTest = $@"
public interface {genInterfaceName}
{{
{interfaceFields}
}}
";

            //this.PathProject_directory +
            System.IO.Directory.CreateDirectory(destinationfullDirectoryPath);
            string combinedPath = Path.Combine(destinationfullDirectoryPath, $@"{fileGeneratedNameWithExt}");

            System.IO.File.WriteAllText(combinedPath, modelAutoGenTest);
        }