Share via


Understanding Recipe References

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies.
This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

A recipe reference is an object that the Recipe Framework uses to associate recipes with launch points, to execute recipes, and to store the state of recipes. Bound recipe references correspond to bound recipes and unbound recipe references correspond to unbound recipes.

Figure 1 illustrates the logical relationship between recipes and recipe references.

Figure 1: Logical relationship between recipes and recipe references

Ff697202.ceb57ff7-d4ac-4af7-bd98-7ca17dc5e43b(en-us,PandP.10).png

Note

Recipe reference information is local to each computer and so it will not be included if the solution is ported to a different computer.

Bound Recipe References

A bound recipe can have a number of bound recipe references, each one associated with an element in a Visual Studio solution. Every time a bound recipe is associated with a solution element, a bound recipe reference is created for that recipe and that element. Logically, the element is stored as the Target property of the bound recipe reference. A bound recipe can be associated with a solution element, either declaratively (by defining the reference in an item, project or solution template) or programmatically (by creating the reference from the action of another recipe).

When the developer right-clicks a solution element, Visual Studio examines all the commands associated with that element's command bar to see if they should be displayed. The Recipe Framework registers the commands representing both bound and unbound recipes with Visual Studio. When Visual Studio queries those commands, the Recipe Framework decides whether they should be shown, by checking to see if there are any recipe references associated with the selected element. If there are, it tells Visual Studio to display the commands associated with the recipe. The command is mapped to the reference, so if the command is selected, the reference executes the recipe represented by the command.

Note

The Recipe Framework creates commands and associates them with the command bar, according to the definition of the recipe itself.

Unbound Recipe References

An unbound recipe has only one reference that is not associated with any element. Instead, the reference contains a single TargetCondition. A TargetCondition is a piece of logic, written in code that returns True when defined conditions are met, as determined by the developer. For example, you may choose to define a TargetCondition that returns True if a solution element has a particular value in its namespace. Although there is only one Target Condition, this does not really represent a restriction on unbound recipe references. Because the TargetCondition is specified in code, it can be as simple or complex as you want.

When a solution element is selected, Visual Studio queries the Recipe Framework to check the status of the TargetCondition of all unbound recipe references. The Recipe Framework then calls the TargetCondition of all unbound recipe references that are defined to be associated with the command bar of the element. If a reference returns True from the TargetCondition, its corresponding command is displayed in the context menu.

See also

Concepts of the Guidance Automation Toolkit | The Recipe Framework | Understanding Recipes | Understanding Wizards | Understanding Visual Studio Templates | Understanding Template and Recipe Associations | Understanding Launch Points | Understanding Guidance Packages | Understanding the Meta Guidance Package