I tried to read Code Elements in classes in a C# solution using an Add-In, but it only reads upto the namespace. I have given below the code that I used. Can any body give me a clue for this matter
Kind Regards,
Imesh
foreach (ProjectItem item in _applicationObject.Solution.Projects.Item(1).ProjectItems) { foreach (CodeElement element in item.FileCodeModel.CodeElements) { try { text = text + element.Name + ","; } catch (Exception e1) { text = e1.Message;} } }
Can I read all the Code Elements with Code Model?
Ideefiks
Kind Regards,
Imesh.
Anish George
The code model is hierarchial, meaning that once you have the CodeElement for a namespace, you need to walk down the children of that element. Cast the CodeElement to CodeNamespace (if it is a namespace, the Kind property will tell you that), then call CodeNamespace.Members to find the child elements of that namespace. Once you have a CodeClass, then call CodeClass.Members to find the children of that node, and so on.
Craig