|
hi guys, i've got a fairly simple (i'd imagine common) wizard, simliar to the HolPackage where u select a config file, click next, select a connection string for a list and then next, the last screen has a custom page. what i'm trying to do is use a valueprovider to preselect the argument value in the for the config file. i.e.
<Argument Name="ConfigurationItem" Type="ProjectItem"> <Converter Type="ProjectItemConverter" /> <ValueProvider Type="ProjectItemByFullNameProvider" ProjectArgumentName="WebProject" ItemFullName="Web.Config" Stage="OnBeginRecipe" /> </Argument>
which is then used in the field:
<Field ValueName="ConfigurationItem" Label="Configuration file" ReadOnly="true"> <Help> Select the configuration file from an existing project in the solution that contains the connection strings to use to connect to a database for the metadata. </Help> <Editor Type="Microsoft.Practices.RecipeFramework.Library.Editors.SolutionPickerEditor, Microsoft.Practices.RecipeFramework.Library, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" UnboundReferenceType="TechControl.GA.Library.References.Unbound.ConfigurationFileRecipeReference, TechControl.GA.Library, Version=1.0.0.0, Culture=neutral" /> </Field>
but it never sets the value in the field. it always makes me select a new one.
also how could i preselect the "default" connection string for the next screen. therefore allowing the user to next through the default values.
i realise i could create custom pages for this but is there a way to do it out of the box???
Regards....
| | mickdelaney Friday, August 03, 2007 9:44 AM | Hi, are you implementing your custom value provider (ProjectItemByFullNameProvider) to get the Configuration Project Item? If so, it may be something wrong in its implementation. Could you post the code for the value provider as well?
You don't need a Custom Page to show the default value for the connection string. In your Connection String argument you could add a monitor that fires the Connection String's value provider when the ConfigurationItem argument changes.
| | Adrian Alonso Friday, August 03, 2007 2:37 PM | I'm glad it worked! Yes, you could implement your own Value Provider that searches for the default value in the selected config file. You will have to use a monitor to execute the Value Provider when the config file argument changes. The implementation of the value provider could read the config file, search for the desired value (maybe this could be set by configuration to Dev, Test, QA, etc) and set the new value. Does this make sense?
-Adrian
| | Adrian Alonso Monday, August 06, 2007 4:45 PM | Hi, are you implementing your custom value provider (ProjectItemByFullNameProvider) to get the Configuration Project Item? If so, it may be something wrong in its implementation. Could you post the code for the value provider as well?
You don't need a Custom Page to show the default value for the connection string. In your Connection String argument you could add a monitor that fires the Connection String's value provider when the ConfigurationItem argument changes.
| | Adrian Alonso Friday, August 03, 2007 2:37 PM | Hi Adrian, I'm using the built in valueprovider.. i.e. Microsoft.Practices.RecipeFramework.Extensions.ValueProviders.VisualStudio.ProjectItemByFullNameProvider
<!-- Project item holding connection string configurations --> <Argument Name="ConfigurationItem" Type="ProjectItem"> <Converter Type="ProjectItemConverter" /> <ValueProvider Type="ProjectItemByFullNameProvider" ProjectArgumentName="WebProject" ItemFullName="Web.Config" Stage="OnBeginRecipe" /> </Argument>
<Page> <Title>Configuration information</Title> <LinkTitle>Configuration information</LinkTitle> <Fields> <Field ValueName="ConfigurationItem" Label="Configuration file" ReadOnly="true"> <Help> Select the configuration file from an existing project in the solution that contains the connection strings to use to connect to a database for the metadata. </Help> <Editor Type="Microsoft.Practices.RecipeFramework.Library.Editors.SolutionPickerEditor, Microsoft.Practices.RecipeFramework.Library, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" UnboundReferenceType="TechControl.GA.Library.References.Unbound.ConfigurationFileRecipeReference, TechControl.GA.Library, Version=1.0.0.0, Culture=neutral" /> </Field> </Fields> </Page> | | mickdelaney Monday, August 06, 2007 8:43 AM | The type you are mentioning is probably included in the Microsoft.Practices.RecipeFramework.Extensions.dll (shipped with WSSF for example but not with GAX/GAT). You could take a look at the WSSF's source code to check how they are using the Value Provider and if it also supports to search project items in web projects. I will keep you posted if I'm able to find the cause of the issue.
| | Adrian Alonso Monday, August 06, 2007 2:40 PM | hi adrian, i checked the source (below), basically it finds the project but not the item within the project (web.config) which is in the root. it just returns null on newValue = DteHelper.FindItemByName(project.ProjectItems, itemFullName, true);i might recompile the library and swap out this for the DteHelperEx version (which i would have thought they'd have used here :-O )
Code Snippet
public override bool OnBeginRecipe(object currentValue, out object newValue) { if(currentValue == null) { IDictionaryService dictservice = (IDictionaryService) ServiceHelper.GetService(this, typeof(IDictionaryService));
Project project = dictservice.GetValue(projectArgumentName) as Project;
if(project != null) { try { newValue = DteHelper.FindItemByName(project.ProjectItems, itemFullName, true); } catch { //With Web projects without any subfolder this method throws an exception newValue = DteHelper.FindItemByName(project.ProjectItems, itemFullName, false); }
if(newValue != null) { return true; } } }
newValue = currentValue; return false; } | | mickdelaney Monday, August 06, 2007 3:48 PM | I changed it to the DteHelperEx version and it worked. i think it was a case issue. (Web.Config instead of Web.config).  DteHelperEx version use ignorecase in its string comparison.cheers for ur assistence again adrian.
| | mickdelaney Monday, August 06, 2007 4:30 PM | You said earlier in the post: "In your Connection String argument you could add a monitor that fires the Connection String's value provider when the ConfigurationItem argument changes."
does this mean u suggest i create a DefaultConnectionStringValueProvider or something.... that would find the default one in the list.... there's often 3 (for each environment etc).
| | mickdelaney Monday, August 06, 2007 4:35 PM | I'm glad it worked! Yes, you could implement your own Value Provider that searches for the default value in the selected config file. You will have to use a monitor to execute the Value Provider when the config file argument changes. The implementation of the value provider could read the config file, search for the desired value (maybe this could be set by configuration to Dev, Test, QA, etc) and set the new value. Does this make sense?
-Adrian
| | Adrian Alonso Monday, August 06, 2007 4:45 PM | yep, thats gr8. cheers.
| | mickdelaney Tuesday, August 07, 2007 9:30 AM |
|