Visual Studio Development Bookmark and Share   
 index > Visual Studio Guidance Automation Toolkit > IExtenderProvider the GAT way...
 

IExtenderProvider the GAT way...

Hello GAT Team!

I have written an Extender for C# projects and for Solutions using the IExtenderProvider. 

Specifically the extender is going after prjCATIDCSharpProjectBrowseObject (4EF9F003-DE95-4d60-96B0-212979F2A857) and vsCATIDSolutionBrowseObject (A2392464-7C22-11d3-BDCA-00C04F688E50).

Based on which object is selected, it provides one of two seperate Extender Objects from the IExtenderProvider::GetExtender method. 

The extender is simply providing some additional properties for use within the PropertyGrid - these properties are being stored within the Solution.Globals collection and Project.Globals collection.

I have plans to extend the current provider to include various files within the project, however with the powerful built-in filtering of recipes and templates provided by the GAT I thought it best to see if there is a way I could use the GAT framework to create a sort of "bound" extender.

Any advice on how to proceed?

Thanks in advance,

 

rdrenker  Tuesday, January 03, 2006 10:27 PM
The following code in your extender provider would do something like what you're looking for:

public object GetExtender(string ExtenderCATID, string ExtenderName, object ExtendeeObject, EnvDTE.IExtenderSite ExtenderSite, int Cookie)
{
    DTE root = (DTE)ExtenderSite.GetObject("");
    // This type is from the Microsoft.Practices.RecipeFramework.VisualStudio.Library.dll in your IDE\PublicAssemblies folder.
   // It provides an System.IServiceProvider interface over the DTE (any OLE service provider, more properly)
    VsServiceProvider provider = new VsServiceProvider(root);

    // This service is the one responsible for managing guidance packages in GAX.
    IRecipeManagerService manager = (IRecipeManagerService)provider.GetService(typeof(IRecipeManagerService));
    GuidancePackage package = null;
   
    // If you want the package to be enabled automatically upon asking for it:
    package = manager.GetPackage("MyPackage");

    // Otherwise, if you want to just get a previously enabled package:
    // package = (GuidancePackage)manager.Components["MyPackage"];

    if (package == null)
    {
        throw new InvalidOperationException("MyPackage is not enabled.");
    }

    // This service manages the bound and unbound references, and can be used to query
    // whether a given recipe is enabled for a given target.
    IAssetReferenceService service = package.GetService<IAssetReferenceService>(true);
    if (service.IsAssetEnabledFor("MyMockExtenderRecipe", DteHelper.GetCurrentSelection(this.Site)))
    {
        // Return the appropriate extender.
    }

    return null;
}

Note that I used a mock recipe to enable the filtering capability. It may be the case that you actually want to have a real recipe doing some actual work too.

HTH
/kzu

kzu  Wednesday, January 04, 2006 8:36 PM
The following code in your extender provider would do something like what you're looking for:

public object GetExtender(string ExtenderCATID, string ExtenderName, object ExtendeeObject, EnvDTE.IExtenderSite ExtenderSite, int Cookie)
{
    DTE root = (DTE)ExtenderSite.GetObject("");
    // This type is from the Microsoft.Practices.RecipeFramework.VisualStudio.Library.dll in your IDE\PublicAssemblies folder.
   // It provides an System.IServiceProvider interface over the DTE (any OLE service provider, more properly)
    VsServiceProvider provider = new VsServiceProvider(root);

    // This service is the one responsible for managing guidance packages in GAX.
    IRecipeManagerService manager = (IRecipeManagerService)provider.GetService(typeof(IRecipeManagerService));
    GuidancePackage package = null;
   
    // If you want the package to be enabled automatically upon asking for it:
    package = manager.GetPackage("MyPackage");

    // Otherwise, if you want to just get a previously enabled package:
    // package = (GuidancePackage)manager.Components["MyPackage"];

    if (package == null)
    {
        throw new InvalidOperationException("MyPackage is not enabled.");
    }

    // This service manages the bound and unbound references, and can be used to query
    // whether a given recipe is enabled for a given target.
    IAssetReferenceService service = package.GetService<IAssetReferenceService>(true);
    if (service.IsAssetEnabledFor("MyMockExtenderRecipe", DteHelper.GetCurrentSelection(this.Site)))
    {
        // Return the appropriate extender.
    }

    return null;
}

Note that I used a mock recipe to enable the filtering capability. It may be the case that you actually want to have a real recipe doing some actual work too.

HTH
/kzu

kzu  Wednesday, January 04, 2006 8:36 PM

You can use google to search for other answers

Custom Search

More Threads

• Server Application Unavailable
• ValueProvider for the first selected Item in a project?
• Not able to create a new Guidance Package project
• How to make item templates appear in "sub categories" in VS 2008
• GAX not wanting to install
• enable/disable - wizard navigation buttons
• Using Project in solution TEmplate
• Unable to update Guidance Automation Extensions to new version
• Ways to turn a project generated by ms guidance package template into a Clarius metafactory template?
• VS2008 Standard vs Professional