Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

How to get the object of the file present in the project in c#?

$
0
0

Hi All,

This is related to extensibility. I want to get the object of the file located in my custom project. when file is opened in the editor i am able to get the object but none of the file is open in the editor then i am not able to get the object.

Please help me.

Regards,

abhishek

 filePath = Path.ChangeExtension(filePath, BackendConstants.LanguageFormat.UsingLocalExtension(Path.GetExtension(filePath)).getFileExt());
            CustomFileNode = null;
            Document doc;
            ProjectItem item;
            Type docType;
            try
            {
                DTE2 dte2 = ServiceProvider.GlobalProvider.GetService(typeof(SDTE)) as DTE2;
                Documents documents = dte2.Documents;

                int count = documents.Count;
                for (int i = 1; i <= count; i++)
                {
                    doc = documents.Item(i);

                    if (doc.ActiveWindow != null)
                    {
                        item = doc.ProjectItem;
                        docType = item.Object.GetType();
                        if (typeof(CustomFileNode) == docType)
                        {
                            CustomFileNode = (CustomFileNode)item.Object;
                            ((CustomProjectNode)node.projectNode).PathChange = true;
                            if (node.Url.Equals(filePath))
                            {
                                fileNode = node;
                                ((CustomProjectNode)node.projectNode).PathChange = false;
                                break;
                            }
                            ((CustomProjectNode)node.projectNode).PathChange = false;

                        }
                    }
                }

                return fileNode;
            }



Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>