Ejemplo n.º 1
0
    public static NamespaceDeclarationSyntax CreateNamespace(
        BaseProjectOptions baseProjectOptions,
        string namespacePart,
        string focusOnSegmentName,
        bool withAutoGen = true)
    {
        ArgumentNullException.ThrowIfNull(baseProjectOptions);
        ArgumentNullException.ThrowIfNull(namespacePart);
        ArgumentNullException.ThrowIfNull(focusOnSegmentName);

        string fullNamespace;

        if (baseProjectOptions.IsForClient)
        {
            fullNamespace = string.IsNullOrEmpty(baseProjectOptions.ClientFolderName)
                ? $"{baseProjectOptions.ProjectName}.{namespacePart}"
                : $"{baseProjectOptions.ProjectName}.{baseProjectOptions.ClientFolderName}.{namespacePart}";
        }
        else
        {
            fullNamespace = $"{baseProjectOptions.ProjectName}.{namespacePart}.{focusOnSegmentName.EnsureFirstCharacterToUpper()}";
        }

        if (withAutoGen)
        {
            return(SyntaxNamespaceDeclarationFactory.Create(
                       baseProjectOptions.ToolNameAndVersion,
                       fullNamespace));
        }

        return(SyntaxNamespaceDeclarationFactory.Create(fullNamespace));
    }
Ejemplo n.º 2
0
    public static NamespaceDeclarationSyntax CreateNamespace(
        BaseProjectOptions baseProjectOptions,
        bool withAutoGen = true)
    {
        ArgumentNullException.ThrowIfNull(baseProjectOptions);

        var fullNamespace = string.IsNullOrEmpty(baseProjectOptions.ClientFolderName)
            ? $"{baseProjectOptions.ProjectName}"
            : $"{baseProjectOptions.ProjectName}.{baseProjectOptions.ClientFolderName}";

        if (withAutoGen)
        {
            return(SyntaxNamespaceDeclarationFactory.Create(
                       baseProjectOptions.ToolNameAndVersion,
                       fullNamespace));
        }

        return(SyntaxNamespaceDeclarationFactory.Create(
                   fullNamespace));
    }