0
クラス名がユーザー提供のプロジェクト名と一致するようにプロジェクトテンプレートを作成したいとします。VSプロジェクトテンプレートのクラス名を変更する
私のクラスは(エクスポートProjectTemplate中)のように定義されます。
namespace $safeprojectname$.ViewModels
{
[Export("$safeprojectname$.ViewModels.TestClassViewModel ",typeof(ContentPaneViewModel))]
[PartCreationPolicy(CreationPolicy.NonShared)]
public class TestClassViewModel : ContentPaneViewModel
{
[ImportingConstructor]
public TestClassViewModel ([Import("$safeprojectname$.Views.TestClassView")]IView theView)
{
View = theView;
View.ViewModel = this;
}
}
}
私ProjectNameは、ABCProjであれば、私はTestClassViewModelがABCProjViewModelとして作成することにしたいです。これを達成するために、プロジェクトテンプレートのクラスファイルを次のように更新しました。
namespace $safeprojectname$.ViewModels
{
[Export("$safeprojectname$.ViewModels.$safeprojectname$",typeof(ContentPaneViewModel))]
[PartCreationPolicy(CreationPolicy.NonShared)]
public class $safeprojectname$: ContentPaneViewModel
{
[ImportingConstructor]
public $safeprojectname$([Import("$safeprojectname$.Views.TestClassView")]IView theView)
{
View = theView;
View.ViewModel = this;
}
}
}
変更を保存してプロジェクトテンプレートzipファイルを再作成しました。しかし、私はこのテンプレートを使用してプロジェクトを作成したとき、私はまだTestClassViewModelとしてclassnameを持っています。
私はここで間違っていますか?
おかげで、私はそれを行うためのより良い方法を考え出した