Visual Studio Development Bookmark and Share   
 index > Visual Studio Guidance Automation Toolkit > Argument with ValueProvider not being replaced in template
 

Argument with ValueProvider not being replaced in template

Hi,

I have a strange problem.

I have a template that uses a recipe to show a wizard with some arguments to feed, and some of these arguments have a value providervalue providerthat monitors another argument that also have a value provider. Here is an example of what I'm talking:

<Arguments>

<Argument Name="SingularEntityName">
<ValueProvider Type="FrameworkGuidancePackage.ValueProviders.DefaultValueProvider, FrameworkGuidancePackage"/>
</Argument>

<Argument Name="LowerSingularEntityName">
<ValueProvider Type="FrameworkGuidancePackage.ValueProviders.LowerEntityNameValueProvider, FrameworkGuidancePackage">
<MonitorArgument Name="SingularEntityName"/>
</ValueProvider>
</Argument>

</Arguments>

The problem is with the argument in bold. When I click Finish on the wizard, and the values get remplaced in the template, the argument LowerSingularEntityName don't get remplaced, but other arguments do.

I tried debugging the code of the value provider, and everything seems to be fine, the newValue is affected but when the arguments get replaced in the template, it's like if the arguments was null.

Here is the code of the value provider if it can help :

public class LowerEntityNameValueProvider : ValueProvider
{
public override bool OnArgumentChanged(string changedArgumentName, object changedArgumentValue, object currentValue, out object newValue)
{
if (changedArgumentValue != null && changedArgumentValue.ToString() != "")
{
newValue = StringUtilities.FirstLetterLowerCase(changedArgumentValue.ToString());
return true;
}
else
{
newValue = null;
return false;
}
}
}

Is the problem caused because the monitored argument has also a ValueProvider, or because the argument is monitoring another argument?

Please help! Smile

Philippe

Philippe Trottier  Thursday, March 06, 2008 4:38 PM

Hi Philippe,

Please contact me at jes AT clariusconsulting.net, so If you want I can send you an example based on your recipe on how to use the valueprovider and monitors. I think that you could have an issue in one of the value providers.

hth.

jose.

Jose Escrich  Tuesday, March 25, 2008 9:00 PM
Hi Philippe,
Can you post how your vstemplate looks? and maybe the entire recipe, what are you using to unfold the template?

thanks.
jose.
Jose Escrich  Tuesday, March 11, 2008 5:48 PM

Hello Jose,

I use an unbound template thatuses a recipe to fill the replacement dictionnary. So here is the .vstemplate :

BusinessComponent.vstemplate

--------------------------------------------------------------------------------

<VSTemplate Version="2.0.0" xmlns="http:/schemas.microsoft.com/developer/vstemplate/2005" Type="Item">
<TemplateData>
<Name>Ajouter un Manager</Name>
<Description>Creation d'un Manager pour une entite (EntityManager)</Description>
<Icon Package="{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}" ID="4515" />
<ProjectType>CSharp</ProjectType>
<SortOrder>20</SortOrder>
<DefaultName>N'entrez rien ici</DefaultName>
</TemplateData>
<TemplateContent>
<References>
<Reference>
<Assembly>System</Assembly>
</Reference>
<Reference>
<Assembly>System.Data</Assembly>
</Reference>
<Reference>
<Assembly>System.Xml</Assembly>
</Reference>
</References>
<ProjectItem OpenInEditor="true" SubType="Code" TargetFileName="$SingularEntityName$Manager.cs" ReplaceParameters="true">EntityManager.cs</ProjectItem>
</TemplateContent>

<WizardExtension>
<Assembly>Microsoft.Practices.RecipeFramework.VisualStudio, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
<FullClassName>Microsoft.Practices.RecipeFramework.VisualStudio.Templates.UnfoldTemplate</FullClassName>
</WizardExtension>
<WizardData>
<Template xmlns="http:/schemas.microsoft.com/pag/gax-template"
SchemaVersion="1.0"
Recipe="AddBusinessComponentRecipe"/>
</WizardData>
</VSTemplate>

--------------------------------------------------------------------------------

And here is the recipe (I removed some arguments to make it clear, but the effect is the same) :

<Recipe Name="AddBusinessComponentRecipe" Bound="false">
<Caption>Add a manager</Caption>

<HostData>
<Icon ID="1429"/>
<CommandBar Name="Project"/>
<CommandBar Name="Project Add"/>
<CommandBar Name="Folder"/>
</HostData>

<Arguments>
<!-- User Input -->
<Argument Name="DevelopperName">
<ValueProvider Type="FrameworkGuidancePackage.ValueProviders.DefaultValueProvider, FrameworkGuidancePackage"/>
</Argument>

<Argument Name="SingularEntityName">
</Argument>

<Argument Name="PlurialEntityName">
<ValueProvider Type="FrameworkGuidancePackage.ValueProviders.PlurialValueProvider, FrameworkGuidancePackage">
<MonitorArgument Name="SingularEntityName"/>
</ValueProvider>
</Argument>

<!-- Derived Arguments -->
<Argument Name="LowerSingularEntityName">
<ValueProvider Type="FrameworkGuidancePackage.ValueProviders.LowerEntityNameValueProvider2, FrameworkGuidancePackage" Expression="$(SingularEntityName)">
<MonitorArgument Name="SingularEntityName"/>
</ValueProvider>
</Argument>

<Argument Name="LowerPlurialEntityName">
<ValueProvider Type="FrameworkGuidancePackage.ValueProviders.LowerEntityNameValueProvider, FrameworkGuidancePackage">
<MonitorArgument Name="PlurialEntityName"/>
</ValueProvider>
</Argument>
</Arguments>

<GatheringServiceData>
<Wizard xmlns="http://schemas.microsoft.com/pag/gax-wizards" SchemaVersion="1.0">
<Pages>
<Page>
<Title>Création d'un nouveau Manager</Title>
<Fields>
<Field ValueName="DevelopperName" Label="Nom du développeur :" />
<Field ValueName="SingularEntityName" Label="Nom de l'entité (Ex: Invoice) :" />
<Field ValueName="PlurialEntityName" Label="Nom de l'entité au pluriel (Ex: Invoices) :" />
</Fields>
</Page>
</Pages>
</Wizard>
</GatheringServiceData>
</Recipe>

So if my comprehension is good, it's the template that calls the recipe. The wizard then shows up. I fill the 3 values and when I click on finish, the template is unfolded by the VS2005 template engine and my replacement values get replaced.

But thevalues that monitors other values seems to have problem in the replacement.

Here is an example of what gets replaced :

Values filled in the wizard :

- DevelopperName : Philippe

- SingularEntityName : Test

- PlurialEntityName : Tests

What should be remplaced in the template :

- DevelopperName : Philippe

- SingularEntityName : Test

- PlurialEntityName : Tests

- LowerSingularEntityName : test

- LowerPlurialEntityName : tests

Values that are actually replaced in the template :

- DevelopperName : Philippe

- SingularEntityName : Test

- PlurialEntityName : Ts

- LowerSingularEntityName : -- (the token is not replaced)

- LowerPlurialEntityName : -- (the token is not replaced)

If you need more info, just tell me!

Thank you for your help!

Phil

Philippe Trottier  Tuesday, March 11, 2008 6:40 PM

It's evident that the problem comes from the <MonitorArgument> clause.

So has anyone ever encountered this problem? Is it a bug, or is there any workaround for this except of creating a custom wizard that fills the values for each of my recipes?

Thanks!

Phil
Philippe Trottier  Monday, March 17, 2008 5:54 PM

Hi Philippe,

Please contact me at jes AT clariusconsulting.net, so If you want I can send you an example based on your recipe on how to use the valueprovider and monitors. I think that you could have an issue in one of the value providers.

hth.

jose.

Jose Escrich  Tuesday, March 25, 2008 9:00 PM

I had EXACTLY the same problem.

Then I put the field on the wizard form. (i am still figuring out how to hide it there)

and now it works.....

Looks like putting it on the form does something with the argument (promote it to somewhere)

Hope it helps you too....

Well0549  Wednesday, March 26, 2008 9:32 AM

You can use google to search for other answers

Custom Search

More Threads

• Guidance Package Manager fails to appear in visual studio 2008
• Inline expression for action inputs? Call receipe programmatically?
• How can you use T3 templates in VS templates???
• Dec '06 WSSF fails to install after installing Feb 07 GAX and GAT
• Any tutorial for GAT?
• creating receipe using short cut
• How to use Generic List in T3
• Get StrongDataSet reference
• MSI Deployment Issues
• Can't Register or Unregister Recipe