Pablo Galiano : Monday, August 25, 2008 - Posts

Subscriptions

<December 2008>
SuMoTuWeThFrSa
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

News

Subscribe to Pablo Galiano by Email

Post Categories

Monday, August 25, 2008 - Posts

How do I know if the solution is still building

My tenth How do I is up.

Scenario

The scenario is really simple, we want to know if the solution is still building. The focus of this How do I shows how to do it.

 

Interfaces and classes needed

 

Code snippet

    public static bool IsSolutionBuilding(IServiceProvider serviceProvider)

    {

        IVsSolutionBuildManager buildManagerService =

            serviceProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager;

 

        int isBuildManagerBusy = 0;

        ErrorHandler.ThrowOnFailure(buildManagerService.QueryBuildManagerBusy(out isBuildManagerBusy));

 

        return (isBuildManagerBusy == 1);

    } 

 

Assemblies needed

  • Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

 

Stay tuned,

Pablo

posted Monday, August 25, 2008 6:40 AM by pga with 2 Comments

How do I know when a model element is being added by a user demand

My ninth How do I is up.

Scenario

Let's say that we have some "Add rules" in our model to perform some custom operation every time a model element is added. One common problem is that we want to perform this operation only when the user creates a model element on demand, this can be translated to the user drags a shape from the toolbox, uses the model explorer, etc. But the add rule is also fired when the store is being deserialized and somehow we need to distinguish both cases. The focus of this How do I tackles this scenario.

 

Interfaces and classes needed

 

Code snippet

    var transaction = e.ModelElement.Store.TransactionManager.CurrentTransaction;

 

    if(transaction != null && !transaction.IsSerializing)

    {

//TODO: perform operation 

    }

 

Assemblies needed

  • Microsoft.VisualStudio.Modeling.Sdk

 

Stay tuned,

Pablo

posted Monday, August 25, 2008 6:32 AM by pga with 1 Comments