Пример #1
0
 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);
             }
         }
     }
 }
Пример #2
0
        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);
                    }
                }
            }
        }