private string AddServices(string fileData, IEntityAdditionOptions options, string projectFolder)
        {
            string contractNamespace = GetContractNamespace(options, projectFolder);

            fileData = UsingStatements.Add(fileData, contractNamespace);

            string projectNamespace = GetProjectNamespace(options, projectFolder);

            fileData = UsingStatements.Add(fileData, projectNamespace);

            // Insert into Startup-Method
            StringEditor stringEditor       = new StringEditor(fileData);
            string       addScopedStatement = GetAddScopedStatement(options.EntityNamePlural, projectFolder);

            stringEditor.NextThatContains($"void Startup{options.Domain}");
            stringEditor.Next();
            stringEditor.NextThatContains("}");

            if (!stringEditor.GetLineAtOffset(-1).Trim().Equals("{"))
            {
                stringEditor.InsertNewLine();
            }
            stringEditor.InsertLine($"            // {options.EntityNamePlural}");
            stringEditor.InsertLine(addScopedStatement);

            return(stringEditor.GetText());
        }
        private string AddUsingStatements(IPropertyAdditionOptions options, string fileData)
        {
            if (options.PropertyType == PropertyTypes.Guid || options.PropertyType == PropertyTypes.DateTime)
            {
                fileData = UsingStatements.Add(fileData, "System");
            }

            return(fileData);
        }
        public void AddRelationToDTO(IRelationSideAdditionOptions options, string domainFolder, string templateFileName, bool forInterface, string namespaceToAdd)
        {
            string filePath = GetFilePath(options, domainFolder, templateFileName);
            string fileData = UpdateFileData(options, filePath, forInterface);

            if (namespaceToAdd != null)
            {
                fileData = UsingStatements.Add(fileData, namespaceToAdd);
            }

            CsharpClassWriter.Write(filePath, fileData);
        }
Example #4
0
        public static void Write(string filePath, string fileData)
        {
            fileData = UsingStatements.Sort(fileData);

            string dirPath = Path.GetDirectoryName(filePath);

            if (!Directory.Exists(dirPath))
            {
                Directory.CreateDirectory(dirPath);
            }

            File.WriteAllText(filePath, fileData);
        }
        private string AddUsingStatements(IRelationSideAdditionOptions options, string fileData)
        {
            if (options.PropertyType == "Guid")
            {
                fileData = UsingStatements.Add(fileData, "System");
            }

            if (options.PropertyType.Contains("Enumerable"))
            {
                fileData = UsingStatements.Add(fileData, "System.Collections.Generic");
            }

            return(fileData);
        }