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
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