Share via


ModelBusEnabledTextTransformation 类

要访问文本模板的代码中的 Visual Studio ModelBus,请在模板的 template 指令的 inherits 特性中指定此类,并将**“hostspecific”** 特性设置为 true。 在模板代码中,可获取 SModelBus 和 SComponentModel 服务。

继承层次结构

System.Object
  Microsoft.VisualStudio.TextTemplating.TextTransformation
    Microsoft.VisualStudio.TextTemplating.VSHost.ModelingTextTransformation
      Microsoft.VisualStudio.TextTemplating.Modeling.ModelBusEnabledTextTransformation

命名空间:  Microsoft.VisualStudio.TextTemplating.Modeling
程序集:  Microsoft.VisualStudio.TextTemplating.Modeling.10.0(在 Microsoft.VisualStudio.TextTemplating.Modeling.10.0.dll 中)

语法

声明
Public MustInherit Class ModelBusEnabledTextTransformation _
    Inherits ModelingTextTransformation
public abstract class ModelBusEnabledTextTransformation : ModelingTextTransformation
public ref class ModelBusEnabledTextTransformation abstract : public ModelingTextTransformation
[<AbstractClass>]
type ModelBusEnabledTextTransformation =  
    class
        inherit ModelingTextTransformation
    end
public abstract class ModelBusEnabledTextTransformation extends ModelingTextTransformation

ModelBusEnabledTextTransformation 类型公开以下成员。

构造函数

  名称 说明
受保护的方法 ModelBusEnabledTextTransformation

页首

属性

  名称 说明
公共属性 CurrentIndent 获取当前的缩进文本,后者将作为生成的每一行文本输出的前缀。 (继承自 TextTransformation。)
公共属性 Errors 基础结构。获取文本模板转换进程的错误集合。 (继承自 TextTransformation。)
受保护的属性 GenerationEnvironment 获取或设置文本模板转换进程用于组合生成的文本输出的字符串。 (继承自 TextTransformation。)
受保护的属性 ModelBus 获取此基类提供的 Visual Studio ModelBus 服务。
受保护的属性 ServiceProvider 返回包含 Visual Studio ModelBus 的服务提供程序。请不要从主机使用服务提供程序。 (重写 ModelingTextTransformation.ServiceProvider。)
公共属性 Session (继承自 ModelingTextTransformation。)
受保护的属性 SkipValidation 如果为 true,则 ValidateStore() 不运行验证,并返回 false。默认值为 false。 (继承自 ModelingTextTransformation。)
受保护的属性 Store 获取模型存储。 (继承自 ModelingTextTransformation。)

页首

方法

  名称 说明
受保护的方法 AddDomainModel 添加存储要加载的域模型类型。在调用 Initialize() 之前为每个域模型调用此方法。 (继承自 ModelingTextTransformation。)
公共方法 ClearIndent CurrentIndent 重置为空字符串。 (继承自 TextTransformation。)
公共方法 Dispose() 释放由 TextTransformation 使用的所有资源。 (继承自 TextTransformation。)
受保护的方法 Dispose(Boolean) (继承自 ModelingTextTransformation。)
公共方法 Equals 确定指定的 Object 是否等于当前的 Object。 (继承自 Object。)
公共方法 Error 创建一个新错误来存储文本模板转换进程期间发生的错误的相关信息。 (继承自 TextTransformation。)
受保护的方法 Finalize 允许 Object 先尝试释放资源并执行其他清理操作,然后再由垃圾回收器回收。由垃圾回收器调用。 (继承自 TextTransformation。)
公共方法 GetHashCode 用作特定类型的哈希函数。 (继承自 Object。)
公共方法 GetType 获取当前实例的 Type。 (继承自 Object。)
公共方法 Initialize 加载使用 AddModel() 指定的模型,并使主机做好处理模板的准备。 (继承自 ModelingTextTransformation。)
受保护的方法 MemberwiseClone 创建当前 Object 的浅表副本。 (继承自 Object。)
受保护的方法 OnSessionChanged 只要提供的会话与上次记住的会话不同即会调用。清除静态 modelbus 实例以准备要读取的模型文件的新快照。 (重写 ModelingTextTransformation.OnSessionChanged(ITextTemplatingSession, ITextTemplatingSession)。)
公共方法 PopIndent CurrentIndent 移除最近添加的文本。 (继承自 TextTransformation。)
公共方法 PushIndent 将文本添加到 CurrentIndent,后者将作为生成的每一行文本输出的前缀。 (继承自 TextTransformation。)
受保护的方法 ReportError 从 ModelBus 错误转换到文本模板错误。基于类别值调用 this.Error 或 this.Warning。
公共方法 ToString 返回表示当前对象的字符串。 (继承自 Object。)
公共方法 TransformText 当在派生类中重写时,将生成转换的文本输出。 (继承自 TextTransformation。)
受保护的方法 ValidateStore 用给定的验证类别验证存储。如果有错误,则返回 true。 (继承自 ModelingTextTransformation。)
公共方法 Warning 创建一个新警告,存储文本模板转换进程期间发生的错误的相关信息。 (继承自 TextTransformation。)
公共方法 Write(String) 向生成的文本输出追加指定字符串的副本。 (继承自 TextTransformation。)
公共方法 Write(String, array<Object[]) 向生成的文本输出追加包含零个或更多格式规范的设置了格式的字符串。每个格式规范由相应对象参数的字符串表示形式替换。 (继承自 TextTransformation。)
公共方法 WriteLine(String) 将指定的字符串副本和默认的行终止符追加到生成的文本输出。 (继承自 TextTransformation。)
公共方法 WriteLine(String, array<Object[]) 向生成的文本输出追加默认的行终止符和包含零个或更多格式规范的设置了格式的字符串。每个格式规范由相应对象参数的字符串表示形式替换。 (继承自 TextTransformation。)

页首

备注

若要在模板中使用此文本转换,您必须在 template 指令中将 hostspecific 特性设置为 true。

示例

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

线程安全

此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。

请参见

参考

Microsoft.VisualStudio.TextTemplating.Modeling 命名空间