/// <summary> /// Execute the command /// </summary> public void Exec() { ModelVisitor visitor = new ModelVisitor(); VSHierarchyWalker walker = new VSHierarchyWalker(visitor); walker.Traverse(_serviceProvider); if (visitor.Models.Count == 0) { try { string solutionName = (string)ServiceLocator.Instance.ShellHelper.Solution.Properties.Item(9).Value; if (solutionName == null) { throw new System.Exception(); } ServiceLocator.Instance.ShellHelper.AddDSLModelToSolution(null, null, solutionName, true); } catch { ServiceLocator.Instance.IDEHelper.ShowError("Can't create new model. You must save the solution before."); } return; } string modelFileName = visitor.Models[0]; if (visitor.Models.Count > 1) { // TODO Affichage pour sélection } ServiceLocator.Instance.ShellHelper.EnsureDocumentOpen(modelFileName, new System.Guid("a347c751-7722-4fa1-b73e-2e03db41d1c9")); // SystemModelEditorFactoryID }
/// <summary> /// Chargement de la stratégie. On recherche les répertoires de config /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> public override void OnLoading(object sender, EventArgs e) { base.OnLoading(sender, e); // Recherche si il existe un répertoire de config FindConfigFolderVisitor visitor = new FindConfigFolderVisitor(this); VSHierarchyWalker walker = new VSHierarchyWalker(visitor); walker.Traverse(ServiceLocator.Instance); }
/// <summary> /// Initializes a new instance of the <see cref="PublishModelCommand"/> class /// à partir du menu général /// </summary> /// <param name="serviceProvider">The service provider.</param> public PublishModelCommand(IServiceProvider serviceProvider) { ModelVisitor visitor = new ModelVisitor(); VSHierarchyWalker walker = new VSHierarchyWalker(visitor); walker.Traverse(serviceProvider); if (visitor.Models.Count > 0) { _fileName = visitor.Models[0]; } }