public void manDepthTest() { var nodeSolution = new NodeSolution(); var root = this.SolutionNode(); Assert.Equal(nodeSolution.MaxDepth(root), 3); }
public void PostorderTest() { var nodeSolution = new NodeSolution(); var root = this.SolutionNode(); var list = nodeSolution.Postorder(root); var expect = new List <int>() { 5, 6, 3, 2, 4, 1 }; Assert.Equal(list, expect); }
public void Test1() { var nodeSolution = new NodeSolution(); var root = this.SolutionNode(); var list = nodeSolution.Preorder(root); var expect = new List <int>() { 1, 3, 5, 6, 2, 4 }; Assert.Equal(list, expect); }
public static CorrelatorPostprocessorOutput Parse(XDocument doc) { if (doc == null) { return(null); } var slnNode = doc.Root.Element(NodeSolution.XmlName); if (slnNode == null) { return(null); } var solution = new NodeSolution(slnNode); var correlatedConnectionIds = doc.Root.Elements("context").Elements("conn-id").Select(e => e.Value).ToHashSet(); return(new CorrelatorPostprocessorOutput(solution, correlatedConnectionIds)); }
/// <summary> /// Ensures that a VS project in the same solution as the project hosting a modeling store references a given project in the same solution (by name) /// </summary> /// <param name="uniqueProjectNameReferencing">Unique project name of the project that needs to reference <paramref name="uniqueProjectNameToReference"/>. Can be null, in that /// case the project is the project holding the model in the store</param> /// <param name="uniqueProjectNameToReference">Unique project nameof the project for which we want to ensure that it is referenced by the VS project hosting the <paramref name="store"/></param> public void EnsureProjectReferencesProject(string uniqueProjectNameReferencing, string uniqueProjectNameToReference) { // Get the referencing project NodeProject referencingProject = null; var sln = new NodeSolution(project.DTE); if (!string.IsNullOrWhiteSpace(uniqueProjectNameReferencing)) referencingProject = sln.Projects.FirstOrDefault(p => p.Name == uniqueProjectNameReferencing); if (referencingProject == null) return; // Add reference to the other project if it is not already referenced VSProject vsProject = referencingProject.VSProject; if (vsProject.References.OfType<Reference>().FirstOrDefault(reference => reference.SourceProject != null && reference.SourceProject.UniqueName == uniqueProjectNameToReference) == null) { NodeProject otherProject = sln.Projects.FirstOrDefault(p => p.Name == uniqueProjectNameToReference); if (otherProject != null) vsProject.References.AddProject(otherProject.Project); } }
public CorrelatorPostprocessorOutput(NodeSolution solution, HashSet <string> correlatedConnectionIds) { this.solution = solution; this.correlatedConnectionIds = correlatedConnectionIds; }
/// <summary> /// initialize the solution managemeent. /// Note : the script attribute "hostspecific" must be "true" /// </summary> public static void InitializeSolution(IServiceProvider host, StringBuilder generationEnvironment) { _generationEnvironment = generationEnvironment; serviceProvider = host; if (serviceProvider != null) Dte = (EnvDTE.DTE)serviceProvider.GetService(typeof(EnvDTE.DTE)); if (Dte == null) throw new Exception("T4 can only execute through the Visual Studio host"); _sln = new NodeSolution(Dte); _context = new Context(); }
void learnFromSolution(NodeSolution solution) { if (solution == null) throw new ArgumentNullException("solution"); // Since we found a solution, record ALL nodes' selection states -- not just the one we were specifically testing. // By doing this, we avoid having to redo work later to check the other nodes' possible selection states. foreach (var pair in solution.Where(p => nodeSolutionPossibilities.ContainsKey(p.Key))) { nodeSolutionPossibilities[pair.Key] |= pair.Value ? NodePossibility.FoundSelectedInSolution : NodePossibility.FoundUnselectedInSolution; } }