private void UsecaseReader_Read() { var usecaseRegion = RegionReader.Where(r => r.RegionName.Contains("Usecase")).FirstOrDefault(); if (usecaseRegion != null) { ContextFileModel.UsecaseSpan = new Span(usecaseRegion.RegionSpan.Start, usecaseRegion.RegionSpan.Length); } }
private void button3_Click(object sender, EventArgs e) { sourcebox.LostFocus += textBox4_TextChanged; destbox.LostFocus += textBox4_TextChanged; lvlbox.LostFocus += textBox4_TextChanged; UpdateMaps(); panel1.AutoScroll = true; pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize; comboBox3.SelectedIndexChanged += comboBox3_SelectedIndexChanged; tabControl1.Selecting += tabControl1_TabIndexChanged; dataGridView1.AutoGenerateColumns = false; dataGridView1.AllowUserToAddRows = false; dataGridView1.RowHeadersVisible = false; dataGridView1.AllowUserToOrderColumns = false; dataGridView1.CellMouseClick += dataGridView1_CellMouseClick; var column0 = new DataGridViewTextBoxColumn() { Name = "column0", HeaderText = "#", SortMode = DataGridViewColumnSortMode.NotSortable, ReadOnly = true }; var column1 = new DataGridViewTextBoxColumn() { Name = "column1", HeaderText = "X", SortMode = DataGridViewColumnSortMode.NotSortable }; var column2 = new DataGridViewTextBoxColumn() { Name = "column2", HeaderText = "Y", SortMode = DataGridViewColumnSortMode.NotSortable }; var column3 = new DataGridViewTextBoxColumn() { Name = "column3", HeaderText = "Z", SortMode = DataGridViewColumnSortMode.NotSortable }; dataGridView1.Columns.Add(column0); dataGridView1.Columns.Add(column1); dataGridView1.Columns.Add(column2); dataGridView1.Columns.Add(column3); _reader = new RegionReader(textBox1.Text); listBox1.DataSource = _reader.Region.Regions; listBox1.DisplayMember = "id"; listBox1.SelectedIndexChanged += listBox1_SelectedIndexChanged; dataGridView1.CellValueChanged += dataGridView1_CellValueChanged; dataGridView1.CurrentCellChanged += dataGridView1_CurrentCellChanged; }
private void InteractionReader_ReadRoleInteractions(ClassDeclarationSyntax parentNode) { for (int i = 0; i < ContextFileModel.Roles.Values.Count; ++i) { var role1 = ContextFileModel.Roles.Values.ElementAt(i); foreach (var roleMethodRegion in RegionReader.Where(r => r.RegionName.Contains(" " + role1.Name + "_Methods"))) { foreach (var node in roleMethodRegion.Nodes) { InteractionReader_FindInteraction(role1, node); } } } }
private void InteractionReader_ReadContextInteractions(ClassDeclarationSyntax parentNode) { var role1 = ContextFileModel.Roles.Values.ElementAt(0); var roleMethodRegion = RegionReader.FirstOrDefault(r => r.RegionName.Contains("Context")); foreach (var node in roleMethodRegion.Nodes) { if (node.HasParentIsKindOf(SyntaxKind.MethodDeclaration) || node.HasParentIsKindOf(SyntaxKind.ConstructorDeclaration)) { InteractionReader_FindInteraction(role1, node); } } }
private void RoleReader_Read(ClassDeclarationSyntax parentNode) { var roleRegion = RegionReader.Where(r => r.RegionName.Contains("Roles")).FirstOrDefault(); if (roleRegion != null) { foreach (var node in roleRegion.Nodes) { if (parentNode == node.Parent) { var roleNodeTypeName = ""; var newRoleName = ""; if (node.IsKind(SyntaxKind.PropertyDeclaration)) { var roleNode = node as PropertyDeclarationSyntax; var roleTypeNode = (roleNode.Type as IdentifierNameSyntax); roleNodeTypeName = roleTypeNode != null?roleTypeNode.Identifier.ToString() : ""; newRoleName = roleNode.Identifier.ToString(); } else if (node.IsKind(SyntaxKind.FieldDeclaration)) { var roleNode = node as FieldDeclarationSyntax; var roleTypeNode = (roleNode.Declaration.Type as IdentifierNameSyntax); roleNodeTypeName = roleTypeNode != null?roleTypeNode.Identifier.ToString() : ""; newRoleName = roleNode.Declaration.Variables[0].Identifier.ToString(); } if (!String.IsNullOrEmpty(newRoleName)) { var newRole = new DCIRole(); newRole.Name = newRoleName; newRole.CodeSpan = new Span(node.Span.Start, node.Span.Length); ContextFileModel.AddRole(newRole); RoleReader_ReadInterface(newRole, roleRegion, roleNodeTypeName, parentNode); RoleReader_ReadMethods(newRole, parentNode); } } } } }
private void RoleReader_ReadMethods(DCIRole role, ClassDeclarationSyntax parentNode) { foreach (var roleMethodRegion in RegionReader.Where(r => r.RegionName.Contains(" " + role.Name + "_Methods"))) { foreach (var node in roleMethodRegion.Nodes) { if (node.IsKind(SyntaxKind.MethodDeclaration) && parentNode == node.Parent) { var methodNode = node as MethodDeclarationSyntax; var roleMethod = new DCIRoleMethod(); var methodName = methodNode.Identifier.ToString(); roleMethod.Name = methodName.Contains("_") ? methodName.Substring(methodName.IndexOf("_") + 1) : methodName; roleMethod.CodeSpan = new Span(methodNode.Span.Start, methodNode.Span.Length); role.AddMethod(roleMethod); } } } }
private void ContextReader_Read(ClassDeclarationSyntax parentNode) { ContextFileModel.Name = parentNode.Identifier.ToString(); ContextFileModel.CodeSpan = new Span(parentNode.Span.Start, parentNode.Span.Length); var contextRegion = RegionReader.Where(r => r.RegionName.Contains("Context")).FirstOrDefault(); if (contextRegion != null) { DCIRole contextRole = null; if (contextRole == null) { contextRole = new DCIRole(); contextRole.Name = parentNode.Identifier.ToString(); contextRole.CodeSpan = new Span(contextRegion.RegionSpan.Start, contextRegion.RegionSpan.Length); ContextFileModel.AddRole(contextRole); } foreach (var node in contextRegion.Nodes) { if (node.IsKind(SyntaxKind.MethodDeclaration) && parentNode == node.Parent) { var methodNode = node as MethodDeclarationSyntax; var roleMethod = new DCIRoleMethod(); var methodName = methodNode.Identifier.ToString(); roleMethod.Name = methodName.Contains("_") ? methodName.Substring(methodName.IndexOf("_") + 1) :methodName; roleMethod.CodeSpan = new Span(methodNode.Span.Start, methodNode.Span.Length); contextRole.AddMethod(roleMethod); } else if (node.IsKind(SyntaxKind.ConstructorDeclaration) && parentNode == node.Parent) { contextRole.CodeSpan = new Span(node.Span.Start, node.Span.Length); } } } }
private void RegionReader_FindAllRegions(SyntaxNode root) { foreach (var regionDirective in root.DescendantTrivia().Where(i => i.IsKind(SyntaxKind.RegionDirectiveTrivia))) { RegionReader.Add(new RegionNodes { RegionDirective = regionDirective }); } var count = 0; foreach (var endRegionDirective in root.DescendantTrivia().Where(i => i.IsKind(SyntaxKind.EndRegionDirectiveTrivia))) { RegionReader[count++].EndRegionDirective = endRegionDirective; } foreach (var node in root.DescendantNodes().Where(i => i is MemberDeclarationSyntax || i is StatementSyntax)) { foreach (var regionNodes in RegionReader) { regionNodes.AddNode(node); } } }
private static void AsyncLoadChunk(Chunk c) { ++_AsyncLoaders; AllChunks.Add(c); RegionReader reader = new RegionReader(ChunkToRegion(c.Position)); LoadChunkDelegate del = reader.LoadChunk; del.BeginInvoke(c, FinishLoadChunk, del); }