Export (0) Print
Expand All

ModelBusEnabledTextTransformation Class

To access Visual Studio ModelBus in the code of a text template, specify this class in the inherits attribute of the template directive of the template, and set the hostspecific attribute to true. In the template code, you can get the SModelBus and SComponentModel services.

Namespace:  Microsoft.VisualStudio.TextTemplating.Modeling
Assembly:  Microsoft.VisualStudio.TextTemplating.Modeling.12.0 (in Microsoft.VisualStudio.TextTemplating.Modeling.12.0.dll)

public abstract class ModelBusEnabledTextTransformation : ModelingTextTransformation

The ModelBusEnabledTextTransformation type exposes the following members.

  NameDescription
Public propertyCurrentIndentGets the current indent text, which is prefixed to each line of the generated text output. (Inherited from TextTransformation.)
Public propertyErrorsInfrastructure. Gets the error collection for the text template transformation process. (Inherited from TextTransformation.)
Protected propertyGenerationEnvironmentGets or sets the string that the text template transformation process is using to assemble the generated text output. (Inherited from TextTransformation.)
Protected propertyModelBusGet the Visual Studio ModelBus service that this base class provides.
Protected propertyServiceProviderReturn a service provider containing the Visual Studio ModelBus. Do not use the service provider from the Host. (Overrides ModelingTextTransformation.ServiceProvider.)
Public propertySession (Inherited from ModelingTextTransformation.)
Protected propertySkipValidationIf true, ValidateStore() does not run validation and returns false. Defaults to false. (Inherited from ModelingTextTransformation.)
Protected propertyStoreGets the modeling Store. (Inherited from ModelingTextTransformation.)
Top

  NameDescription
Protected methodAddDomainModelAdd a domain model type to be loaded by the Store. Call this for each domain model before calling Initialize(). (Inherited from ModelingTextTransformation.)
Public methodClearIndentResets the CurrentIndent to an empty string. (Inherited from TextTransformation.)
Public methodDispose()Releases all resources used by the TextTransformation. (Inherited from TextTransformation.)
Protected methodDispose(Boolean) (Inherited from ModelingTextTransformation.)
Public methodEqualsDetermines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodErrorCreates a new error to store information about errors that occur during the text template transformation process. (Inherited from TextTransformation.)
Protected methodFinalizeAllows an Object to attempt to free resources and perform other cleanup operations before it is reclaimed by the garbage collector. Called by the garbage collector. (Inherited from TextTransformation.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInitializeLoads the models specified using AddModel() and makes the host ready to process the template. (Inherited from ModelingTextTransformation.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodOnSessionChangedCalled whenever a session is provided that isn't the same as the last remembered session. Clears the static modelbus instance to prepare for a new snapshot of model files to be read. (Overrides ModelingTextTransformation.OnSessionChanged(ITextTemplatingSession, ITextTemplatingSession).)
Public methodPopIndentRemoves the most recently added text from CurrentIndent. (Inherited from TextTransformation.)
Public methodPushIndentAdds text to CurrentIndent, which is prefixed to each line of the generated text output. (Inherited from TextTransformation.)
Protected methodReportErrorConverts from ModelBus errors to Text Template errors. Calls this.Error or this.Warning depending on the category value.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodTransformTextWhen overridden in a derived class, generates the text output of the transformation. (Inherited from TextTransformation.)
Protected methodValidateStoreValidates the store with the given validation categories. Returns true if there are errors. (Inherited from ModelingTextTransformation.)
Public methodWarningCreates a new warning to store information about errors that occur during the text template transformation process. (Inherited from TextTransformation.)
Public methodWrite(String)Appends a copy of the specified string to the generated text output. (Inherited from TextTransformation.)
Public methodWrite(String, Object[])Appends a formatted string, which contains zero or more format specifications, to the generated text output. Each format specification is replaced by the string representation of a corresponding object argument. (Inherited from TextTransformation.)
Public methodWriteLine(String)Appends a copy of the specified string and the default line terminator to the generated text output. (Inherited from TextTransformation.)
Public methodWriteLine(String, Object[])Appends a formatted string, which contains zero or more format specifications, and the default line terminator, to the generated text output. Each format specification is replaced by the string representation of a corresponding object argument. (Inherited from TextTransformation.)
Top

To use this text transformation in a template, you must set the hostspecific attribute to true in the template directive.

<#@ template debug="false" hostspecific="true" language="C#" inherits="Microsoft.VisualStudio.TextTemplating.Modeling.ModelBusEnabledTextTransformation" #>
<#@ assembly name="Microsoft.VisualStudio.TextTemplating.Modeling.11.0.dll" #>
<#@ assembly name="Microsoft.VisualStudio.Modeling.Sdk.Integration.11.0.dll" #>
<#@ import namespace="Microsoft.VisualStudio.Modeling.Integration" #>
<#@ output extension=".txt" #>
<# IModelBus modelbus = this.ServiceProvider.GetService(typeof(SModelBus)) as IModelBus; 
...
#>

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft