/// <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 }
public void ModelVisitor_ReturnsCorrectPropertyName() { // Arrange var visitor = new ModelVisitor(); Expression <Func <ContactGetModel, object> > selector = c => new { CompanyName = c.CompanyName.ToUpper(CultureInfo.InvariantCulture), Currency = c.Country.Currency.Name, Bank = c.Bank.Name, Name = c.Firstname + " " + c.Surname, Address = $"{c.Street} {c.City} {c.PostalCode}", Discount = c.CompanyName.Length > 10 ? 10.0m : c.DiscountPercentage }; // Act visitor.Visit(selector); var memberNames = visitor.MemberNames.ToList(); // Assert Assert.AreEqual(12, memberNames.Count); Assert.Contains("CompanyName", memberNames); Assert.Contains("Country", memberNames); Assert.Contains("Country.Currency", memberNames); Assert.Contains("Country.Currency.Name", memberNames); Assert.Contains("Bank", memberNames); Assert.Contains("Bank.Name", memberNames); Assert.Contains("Firstname", memberNames); Assert.Contains("Surname", memberNames); Assert.Contains("Street", memberNames); Assert.Contains("City", memberNames); Assert.Contains("PostalCode", memberNames); Assert.Contains("DiscountPercentage", memberNames); }
/// <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]; } }
public void visitReferences(ModelVisitor mv) { this.deleg.visitReferences(mv); }
public void visitNotContained(ModelVisitor mv) { this.deleg.visitNotContained(mv); }
public void visit(ModelVisitor mv, bool b1, bool b2, bool b3) { this.deleg.visit(mv, b1, b2, b3); }
public void deepVisitContained(ModelVisitor mv) { this.deleg.deepVisitContained(mv); }
public void deepVisitReferences(ModelVisitor mv) { deleg.deepVisitReferences(mv); }
public void deepVisitNotContained(ModelVisitor mv) { deleg.deepVisitNotContained(mv); }
public void visitContained(ModelVisitor mv) { deleg.visitContained(mv); }