param(
    [string]$FilePath,
    [string]$Category
)

if (-not (Test-Path $FilePath)) {
    Write-Error "File not found: $FilePath"
    return
}

$content = Get-Content $FilePath -Raw

if ($content -match '(\s+public static string NombreClase\(\)\s+\{\s+return ".*?";\s+\})') {
    $nombreclaseMethod = $matches[1]
    $newMethod = "$nombreclaseMethod

        public static string NombreCategoria()
        {
            return `"$Category`";
        }"
    
    $newContent = $content -replace [regex]::Escape($nombreclaseMethod), $newMethod
    
    if ($content -notmatch 'public static string NombreCategoria\(\)') {
        Set-Content $FilePath -Value $newContent -NoNewline
        Write-Host "Updated: $FilePath"
    } else {
        Write-Host "Skipped (already has NombreCategoria): $FilePath"
    }
} else {
    Write-Warning "Could not find NombreClase method in: $FilePath"
}
