Example #1
0
        //
        /// <summary>
        /// We come here : After a Project load (xFile == NULL), or after a File Save (xFile == the Saved file)
        /// </summary>
        private void OnFileWalkComplete(XFile xfile)
        {
            if (xfile == null)
            {
                return;
            }
            // Retrieve the corresponding node
            if (!xfile.HasCode || XSolution.IsClosing)
            {
                return;
            }
            //
            if (xfile.Virtual)
            {
                return;
            }
            XSharpProjectNode prjNode = (XSharpProjectNode)xfile.Project.ProjectNode;

            Microsoft.VisualStudio.Project.HierarchyNode node = prjNode.FindURL(xfile.FullPath);
            if (node != null)
            {
                XSharpModuleId module = new XSharpModuleId(prjNode.InteropSafeHierarchy, node.ID);
                module.ContentHashCode = xfile.ContentHashCode;
                CreateUpdateTreeRequest(xfile.SourcePath, module);
            }
        }
Example #2
0
        internal String GetParentName()
        {
            // There needs to be a better way to handle this
            // CS uses a table with
            // Parent extension, Allowed child extensions
            // look at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Projects\{FAE04EC0-301F-11d3-BF4B-00C04F79EFBC}\RelatedFiles
            // .xaml .xaml.cs
            // .cs   .designer.cs, .resx
            // .xsd  .cs, .xsc, .xss, .xsx
            // .resx files (like Resources.resx) seem to be handled differently..
            // we can hard code a similar table or read it from the registry like C# does.
            // CS also defines a 'relationtype'. See the CS Project System source code.
            String            path    = Path.GetFileName(this.Url).ToLowerInvariant();
            String            folder  = Path.GetDirectoryName(this.Url) + "\\";
            XSharpProjectNode project = this.ProjectMgr as XSharpProjectNode;
            int relationIndex         = path.IndexOf(".");

            switch (this.FileType)
            {
            case XFileType.Header:
            case XFileType.ManagedResource:
                path = Path.ChangeExtension(path, ".prg");
                if (project.FindURL(folder + path) == null)
                {
                    path = null;
                }
                break;

            case XFileType.VODBServer:
            case XFileType.VOFieldSpec:
            case XFileType.VOForm:
            case XFileType.VOIndex:
            case XFileType.VOMenu:
            case XFileType.VOOrder:
            case XFileType.NativeResource:
                if (relationIndex >= 0)
                {
                    path = path.Substring(0, relationIndex) + ".prg";
                    if (project.FindURL(folder + path) == null)
                    {
                        path = null;
                    }
                }
                else
                {
                    path = null;
                }
                break;

            default:
                if (path.EndsWith(".designer.prg"))
                {
                    // could be Form.Prg
                    // Resources.resx
                    // Settings.Settings
                    path = path.Substring(0, relationIndex);
                    string parent = folder + path + ".prg";
                    if (project.FindURL(parent) != null)
                    {
                        return(parent);
                    }
                    parent = folder + path + ".resx";
                    if (project.FindURL(parent) != null)
                    {
                        return(parent);
                    }
                    parent = folder + path + ".settings";
                    if (project.FindURL(parent) != null)
                    {
                        return(parent);
                    }
                    return("");
                }
                else if (path.EndsWith(".xaml.prg"))
                {
                    path = path.Substring(0, relationIndex) + ".xaml";
                    if (project.FindURL(folder + path) == null)
                    {
                        path = null;
                    }
                }
                else
                {
                    path = string.Empty;
                }
                break;
            }
            if (!String.IsNullOrEmpty(path))
            {
                String dir = Path.GetDirectoryName(this.Url);
                if (dir.EndsWith("\\resources"))
                {
                    dir = dir.Substring(0, dir.Length - "\\resources".Length);
                }
                path = dir + "\\" + path;
            }
            return(path);
        }