TextTransformation.PushIndent (Método)
Agrega texto a CurrentIndent, que se agrega como prefijo a cada línea del resultado de texto generado.
Espacio de nombres: Microsoft.VisualStudio.TextTemplating
Ensamblado: Microsoft.VisualStudio.TextTemplating.12.0 (en Microsoft.VisualStudio.TextTemplating.12.0.dll)
Sintaxis
'Declaración
Public Sub PushIndent ( _
indent As String _
)
public void PushIndent(
string indent
)
public:
void PushIndent(
String^ indent
)
member PushIndent :
indent:string -> unit
public function PushIndent(
indent : String
)
Parámetros
indent
Tipo: StringTexto que se va a agregar a CurrentIndent. Si CurrentIndent ya contiene texto, indent se anexa al texto existente.
Comentarios
CurrentIndent representa texto que se lleva como prefijo cada línea de la salida de texto generada. La sangría aplicada al texto puede ser sólo espacios, por ejemplo " ", o puede incluir palabras. PushIndent agrega texto a CurrentIndenty se puede llamar más de una vez. PopIndent quita el último texto agregado de CurrentIndenty se puede llamar más de una vez. ClearIndent quita todo el texto de CurrentIndent.
Ejemplos
Los ejemplos de código siguientes muestran cómo llamar al método PushIndent desde una plantilla de texto. Pegue estos ejemplos de código en cualquier archivo de plantilla del texto y ejecute la transformación de plantilla de texto para ver los resultados.
Este ejemplo llama el método PushIndent y agrega cuatro espacios como sangría. Observe que la sangría de las instrucciones WriteLine en el código no afecta a la sangría del resultado.
<#
PushIndent(" ");
WriteLine("Hello");
WriteLine("How are you?");
WriteLine("Goodbye");
ClearIndent();
#>
<#
PushIndent(" ")
WriteLine("Hello")
WriteLine("How are you?")
WriteLine("Goodbye")
ClearIndent()
#>
Este ejemplo produce el siguiente resultado.
Hello
How are you?
Goodbye
En el ejemplo siguiente se llama al método PushIndent varias veces. La primera vez agrega cuatro espacios como la sangría, la segunda vez agrega cuatro espacios adicionales como la sangría.
<#
PushIndent(" ");
WriteLine("Hello");
WriteLine("How are you?");
PushIndent(" ");
WriteLine("I am fine, thank you. How are you?");
PopIndent();
WriteLine("I am fine too, thank you.");
WriteLine("Goodbye");
PushIndent(" ");
WriteLine("Goodbye");
ClearIndent();
#>
<#
PushIndent(" ")
WriteLine("Hello")
WriteLine("How are you?")
PushIndent(" ")
WriteLine("I am fine, thank you. How are you?")
PopIndent()
WriteLine("I am fine too, thank you.")
WriteLine("Goodbye")
PushIndent(" ")
WriteLine("Goodbye")
ClearIndent()
#>
Este ejemplo produce el siguiente resultado.
Hello
How are you?
I am fine, thank you. How are you?
I am fine too, thank you.
Goodbye
Goodbye
En el ejemplo siguiente se llama el método PushIndent y se incluyen palabras en la sangría aplicada al texto.
<#
WriteLine("The first five numbers:");
PushIndent(" Number: ");
for(int i=1; i<6; i++)
{
WriteLine(i.ToString());
}
ClearIndent();
#>
<#
WriteLine("The first five numbers:")
PushIndent(" Number: ")
For i as integer = 1 To 5
WriteLine(i.ToString())
Next
ClearIndent()
#>
Este ejemplo produce el siguiente resultado.
The first five numbers:
Number: 1
Number: 2
Number: 3
Number: 4
Number: 5
Seguridad de .NET Framework
- Plena confianza para el llamador inmediato. Un código de confianza parcial no puede utilizar este miembro. Para obtener más información, vea Utilizar bibliotecas de código que no es de plena confianza.
Vea también
Referencia
Microsoft.VisualStudio.TextTemplating (Espacio de nombres)