2012-12-10 16 views
8

Sto creando un modello di elemento di Visual Studio per creare alcuni file che dipendono da un file 'contenitore'.

L'ultimo file <ProjectItem SubType="Code" TargetFileName="$fileinputname$\I$fileinputname$ View.cs" ReplaceParameters="true">Container View.cs</ProjectItem> crea un'interfaccia di visualizzazione che prevede un determinato tipo di modello. Tuttavia il parametro $safeitemname$ non ha funzionato come previsto.

uscita Container View.cs di file:

public interface IIMy_Triplet_View : IView<IMy_Triplet_View_Model> 
{ 
} 

atteso:

public interface IMy_Triplet_View : IView<My_Triplet_Model> 
{ 
} 

questa è la fonte per il modello contenitore View.cs:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using WebFormsMvp; 

namespace $rootnamespace$ 
{ 
    public interface $safeitemname$_View : IView<$safeitemname$_Model> 
    { 
    } 
} 

e il file .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> 

risposta

14

soluzione trovata qui: http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/8516524a-22d3-4ed2-b2da-aaafe855fb92/

Aggiungi un CustomParameter (ultima voce in TemplateContent):

<VSTemplate Version="3.0.0" ... Type="Item"> 
<TemplateData> 
    ... 
</TemplateData> 
<TemplateContent> 
    ... 
    <CustomParameters> 
    <CustomParameter Name="$basename$" Value="$fileinputname$"/> 
    </CustomParameters> 
</TemplateContent> 
</VSTemplate> 

E l'uso $ basename $ nei file invece di $ fileinputname $.

Problemi correlati