Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Visual studio项目模板$safeitemname$未按预期工作_C#_Visual Studio_Parameters_Visual Studio Templates - Fatal编程技术网

C# Visual studio项目模板$safeitemname$未按预期工作

C# Visual studio项目模板$safeitemname$未按预期工作,c#,visual-studio,parameters,visual-studio-templates,C#,Visual Studio,Parameters,Visual Studio Templates,我正在创建一个VisualStudio项目模板来创建一些依赖于“容器”文件的文件 最后一个文件Container View.cs创建了一个需要特定模型类型的视图界面但是,$safeitemname$参数没有像我预期的那样工作 输出容器视图.cs文件: public interface IIMy_Triplet_View : IView<IMy_Triplet_View_Model> { } 公共接口IIMy\u Triplet\u视图:IView { } 期望值: public

我正在创建一个VisualStudio项目模板来创建一些依赖于“容器”文件的文件

最后一个文件
Container View.cs
创建了一个需要特定模型类型的视图界面但是,
$safeitemname$
参数没有像我预期的那样工作

输出容器视图.cs文件:

public interface IIMy_Triplet_View : IView<IMy_Triplet_View_Model>
{
}
公共接口IIMy\u Triplet\u视图:IView
{
}
期望值:

public interface IMy_Triplet_View : IView<My_Triplet_Model>
{
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WebFormsMvp;

namespace $rootnamespace$
{
    public interface $safeitemname$_View : IView<$safeitemname$_Model>
    {
    }
}
公共接口IMy\u三元组视图:IView
{
}
这是Container View.cs模板的源代码:

public interface IMy_Triplet_View : IView<My_Triplet_Model>
{
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WebFormsMvp;

namespace $rootnamespace$
{
    public interface $safeitemname$_View : IView<$safeitemname$_Model>
    {
    }
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.Web;
使用WebFormsMvp;
名称空间$rootnamespace$
{
公共接口$safeitemname$\u视图:IView
{
}
}
和.vstemplate文件

    <VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item">
      <TemplateData>
        <DefaultName>Model-View-Presenter</DefaultName>
        <Name>Model-View-Presenter</Name>
        <Description>Creates a model-view-presenter triplet</Description>
        <ProjectType>CSharp</ProjectType>
        <SortOrder>10</SortOrder>
        <Icon>__TemplateIcon.png</Icon>
        <PreviewImage>__PreviewImage.png</PreviewImage>
      </TemplateData>
      <TemplateContent>
        <References>
          <Reference>
            <Assembly>WebFormsMvp</Assembly>
          </Reference>
        </References>
        <ProjectItem SubType="Code" TargetFileName="$fileinputname$" ReplaceParameters="false">Container</ProjectItem>
        <ProjectItem SubType="Code" TargetFileName="$fileinputname$\$fileinputname$ Model.cs" ReplaceParameters="true">Container Model.cs</ProjectItem>
        <ProjectItem SubType="Code" TargetFileName="$fileinputname$\$fileinputname$ Presenter.cs" ReplaceParameters="true">Container Presenter.cs</ProjectItem>
        <ProjectItem SubType="Code" TargetFileName="$fileinputname$\I$fileinputname$ View.cs" ReplaceParameters="true">Container View.cs</ProjectItem>
      </TemplateContent>
    </VSTemplate>

表示器
表示器
创建模型视图演示器三元组
CSharp
10
__TemplateIcon.png
__PreviewImage.png
WebFormsMvp
容器
容器模型.cs
容器演示器.cs
容器视图.cs
在此处找到解决方案:

添加CustomParameter(TemplateContent下的最后一项):


...
...
并在文件中使用$basename$,而不是$fileinputname$