public virtual List <CSClass> ParseString(string data, string filePath, string projectDirectory, IEnumerable <CSClass> existingClassList) { string relativeFilePath = filePath.Replace(projectDirectory, ""); if (relativeFilePath.StartsWith("\\")) { relativeFilePath = relativeFilePath.Substring(1); } List <CSClass> returnValue = new List <CSClass>(existingClassList ?? new CSClass[] {}); var parser = new CSharpParser(); var compilationUnit = parser.Parse(data, filePath); var namespaceNodeList = compilationUnit.Children.Where(i => i is NamespaceDeclaration); foreach (NamespaceDeclaration namespaceNode in namespaceNodeList) { var typeDeclarationNodeList = namespaceNode.Children.Where(i => i is TypeDeclaration); foreach (TypeDeclaration typeDeclarationNode in typeDeclarationNodeList) { var classObject = returnValue.SingleOrDefault(i => i.ClassName == typeDeclarationNode.Name && i.NamespaceName == namespaceNode.FullName); if (classObject == null) { classObject = new CSClass { NamespaceName = namespaceNode.FullName, ClassName = typeDeclarationNode.Name }; returnValue.Add(classObject); } ClassParser.BuildClass(classObject, typeDeclarationNode, relativeFilePath); } } return(returnValue); }