private void InitializeRecipeCommands() { IMenuCommandService mcs = GetService <IMenuCommandService>(true); Guid guidancePackageGuid = new Guid(guidancePackage.Configuration.Guid); if (guidancePackage.Configuration.Recipes == null) { return; } if (guidancePackage.Configuration.Recipes.Length >= 255) { throw new InvalidOperationException(Properties.Resources.Recipes_MaximumExceeded); } for (int iRecipe = 0; iRecipe < guidancePackage.Configuration.Recipes.Length; iRecipe++) { Configuration.Recipe recipe = guidancePackage.Configuration.Recipes[iRecipe]; if (recipe.HostData != null && recipe.HostData.CommandBar != null) { CommandID cmd = new CommandID(guidancePackageGuid, (iRecipe + 1) * 0x100); MenuCommand menuCmd = new RecipeMenuCommand(recipe, this.guidancePackage, this, cmd); mcs.AddCommand(menuCmd); commands.Add(menuCmd); } } }
protected override void OnSited() { base.OnSited(); IConfigurationService configService = GetService<IConfigurationService>(true); this.recipeConfig = (Configuration.Recipe)configService.CurrentPackage[recipeReference.AssetName]; managerService = GetService<IRecipeManagerService>(true); }
/// <summary> /// See <see cref="IAssetReferenceService.Add(IAssetReference, IDictionary)"/>. /// </summary> public void Add(IAssetReference reference, IDictionary initialState) { if (reference is RecipeReference) { IConfigurationService configuration = GetService <IConfigurationService>(true); // The configuration service will throw if the recipe doesn't exist. Configuration.Recipe recipeReferenced = configuration.CurrentPackage[reference.AssetName]; } Add(reference, initialState, false); }
private void AddTemplateCommand(IVsTemplate template) { if (template.Kind == TemplateKind.Solution) { return; } Configuration.RecipeHostData hostData = null; if (template.ExtensionData != null && !string.IsNullOrEmpty(template.ExtensionData.Recipe)) { Configuration.Recipe recipeConfig = GetRecipeConfig(template.ExtensionData.Recipe); if (recipeConfig != null && recipeConfig.HostData != null && recipeConfig.HostData.CommandBar != null) { hostData = recipeConfig.HostData; // Set the host data to null to avoid registering two commands recipeConfig.HostData = null; } } int priority = CTCBuilder.defaultPriority; CommandID icon = CreateBitmap(template); if (hostData != null) { hostData.Icon = new Configuration.Icon(); hostData.Icon.Guid = icon.Guid.ToString(); hostData.Icon.ID = icon.ID; priority = hostData.Priority; } ; Button myButton = new Button(template.Command, this.PackageGroup.Group, priority, icon, CommandType.Button, Util.DisabledDefault, guidancePackage.Caption + "." + template.Name); AddCommand(myButton, hostData); if (hostData == null) { // Add the template command in the standard places CommandID parentCommand = null; if (template.Kind == TemplateKind.ProjectItem) { parentCommand = ShellCmdDef.GetPredefinedCommandID(Configuration.CommandBarName.ProjectAdd); AddGroupPlacement(myButton, parentCommand); } else if (template.Kind == TemplateKind.Project) { parentCommand = ShellCmdDef.GetPredefinedCommandID(Configuration.CommandBarName.SolutionAdd); AddGroupPlacement(myButton, parentCommand); } parentCommand = ShellCmdDef.GetPredefinedCommandID(Configuration.CommandBarName.SolutionFolderAdd); AddGroupPlacement(myButton, parentCommand); } }
public RecipeMenuCommand(Configuration.Recipe recipe, GuidancePackage guidancePackage, Microsoft.Practices.ComponentModel.ServiceContainer serviceProvider, CommandID commandId) : base(guidancePackage, serviceProvider, commandId) { if (recipe == null) { throw new ArgumentNullException("recipe"); } this.recipe = recipe; this.Text = recipe.Caption; }
private void ProcessT4Templates() { T4UnfoldAction action = new T4UnfoldAction(); UnfoldTemplate template = (UnfoldTemplate)UnfoldTemplate.UnfoldingTemplates.Peek(); if (template.Template.VSKind == WizardRunKind.AsMultiProject) { // We dont process any T4 template for a multiproject template return; } try { package.Add(action); IConfigurationService configService = package.GetService <IConfigurationService>(true); IVsTemplate vsTemplate = template.Template; Configuration.Recipe recipe = null; if (vsTemplate != null && vsTemplate.ExtensionData != null && !string.IsNullOrEmpty(vsTemplate.ExtensionData.Recipe)) { recipe = configService.CurrentPackage[vsTemplate.ExtensionData.Recipe]; } if (recipe != null && recipe.Arguments != null) { IDictionaryService dictService = GetService <IDictionaryService>(); PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(action); foreach (Configuration.Argument recipeArg in recipe.Arguments) { object value = dictService.GetValue(recipeArg.Name); properties[recipeArg.Name].SetValue(action, value); } } action.Project = template.generatedProject; action.ProjectItemCollection = template.generatedItems; action.Execute(); } catch (Exception ex) { // We will swallow the exception, the erroneous references did not get added ErrorHelper.Show(this, ex); } finally { if (action != null) { package.Remove(action); action.Dispose(); action = null; } } }
private void CheckConflictingArguments(UnfoldTemplate parentTemplate) { Configuration.Recipe parentRecipe = parentTemplate.RecipeConfig; if (RecipeConfig != null && parentRecipe != null && RecipeConfig.Arguments != null) { foreach (Configuration.Argument arg in RecipeConfig.Arguments) { foreach (Configuration.Argument argParent in parentRecipe.Arguments) { if (arg.Name.Equals(argParent.Name)) { throw new RecipeFrameworkException( String.Format(CultureInfo.CurrentCulture, Properties.Resources.Templates_ArgumentsShared, arg.Name, RecipeConfig.Name, parentRecipe.Name)); } } } } }
private void BuiltRecipeCommands() { if (guidancePackage.Recipes == null) { return; } for (int iRecipe = 0; iRecipe < guidancePackage.Recipes.Length; iRecipe++) { Configuration.Recipe recipe = guidancePackage.Recipes[iRecipe]; if (recipe.HostData != null && recipe.HostData.CommandBar != null) { CommandID myCommand = new CommandID(guidRecipeFrameworkPkgCmdSet, (iRecipe + 1) * 0x100); CommandID icon = CreateBitmap(recipe.HostData.Icon); Button myButton = new Button(myCommand, this.PackageGroup.Group, recipe.HostData.Priority, icon, CommandType.Button, Util.DisabledDefault, guidancePackage.Caption + "." + recipe.Name); AddCommand(myButton, recipe.HostData); } } }
/// <summary> /// Initializes the data class. /// </summary> /// <param name="recipe">The recipe instance for the event.</param> /// <param name="executedFromTemplate">Tells if the recipe was executed because the unfolding of a template</param> public RecipeEventArgs(Configuration.Recipe recipe, bool executedFromTemplate) { this.recipe = recipe; this.executedFromTemplate = executedFromTemplate; }