Compartir a través de


TextTransformation Class

Definition

Base class for generated text transformations

public ref class TextTransformation abstract : IDisposable
public abstract class TextTransformation : IDisposable
type TextTransformation = class
    interface IDisposable
Public MustInherit Class TextTransformation
Implements IDisposable
Inheritance
TextTransformation
Derived
Implements

Remarks

Any class specified in an inherits directive must match this class in a duck-typing style.

Note that this class therefore specifies an implicit contract with the transformation object. The object doesn't have to derive from any specific type or interface, but it must have a) A void Initialize() method. b) A string TransformText() method c) An Errors property that's duck-compatible with CompilerErrorCollection d) A GeneratonEnvironment property that's duck-compatible with StringBuilder. e) A void Write(string) method

Using any further features of T4 such as expression blocks will require the class to have further methods, such as ToStringHelper, but those will produce regular compiler errors at transform time that the base class author can address.

These few methods together form a subset of the TextTransformation default base class' API.

If you change this pseudo-contract to add more requirements, you should consider this a breaking change. It's OK, however, to change the contract to have fewer requirements.

Constructors

TextTransformation()

Properties

CurrentIndent

Gets the current indent we use when adding lines to the output

Errors

The error collection for the generation process

GenerationEnvironment

The string builder that generation-time code is using to assemble generated output

Session

Current transformation session

Methods

ClearIndent()

Remove any indentation

Dispose()

Disposes the state of this object.

Dispose(Boolean)

Dispose implementation.

Error(String)

Raise an error

Finalize()

Finaizlier.

Initialize()

Initialize the templating class

PopIndent()

Remove the last indent that was added with PushIndent

PushIndent(String)

Increase the indent

TransformText()

Generate the output text of the transformation

Warning(String)

Raise a warning

Write(String, Object[])

Write formatted text directly into the generated output

Write(String)

Write text directly into the generated output

WriteLine(String, Object[])

Write formatted text directly into the generated output

WriteLine(String)

Write text directly into the generated output

Applies to