コード例 #1
0
ファイル: ProjectReference.cs プロジェクト: johnx7271/OpenGAX
            public string GetSerializationData(object target)
            {
                Project targetProject = target as Project;

                if (targetProject == null)
                {
                    throw new ArgumentException("target");
                }

                VSWebSite targetSite = targetProject.Object as VSWebSite;
                webType   kind       = (webType)targetProject.Properties.Item("WebSiteType").Value;

                string location = targetProject.UniqueName;

                if (kind == webType.webTypeFileSystem)
                {
                    string slnPath = Path.GetDirectoryName(targetProject.DTE.Solution.FileName);
                    if (targetProject.UniqueName.StartsWith(slnPath))
                    {
                        location = targetProject.UniqueName.Replace(slnPath, "");
                    }
                    // If not under the solution, we will persist the full path. It will
                    // work as long as the developer does not move the website around.
                    // A warning is issued at connection or construction time.
                }

                return(String.Join("|", new string[] { kind.ToString(), location }));
            }
コード例 #2
0
ファイル: ProjectReference.cs プロジェクト: yovannyr/OpenGAX
            internal void IssueWebSiteLocationWarning(Project webSite)
            {
                webType kind = (webType)webSite.Properties.Item("WebSiteType").Value;

                if (kind == webType.webTypeFileSystem &&
                    HasDriveSpecification(webSite.UniqueName) &&
                    /* During the unfold process, the solution does not have a filename */
                    webSite.DTE.Solution.FileName.Length > 0 &&
                    !webSite.UniqueName.StartsWith(Path.GetDirectoryName(webSite.DTE.Solution.FileName)))
                {
                    Trace.TraceWarning(Properties.Resources.WebProjectReference_FileSystemWebNotUnderSolution,
                                       webSite.UniqueName);
                }
            }
コード例 #3
0
ファイル: ProjectReference.cs プロジェクト: johnx7271/OpenGAX
            public object LocateTarget(IServiceProvider serviceProvider, string serializedData)
            {
                DTE vs = (DTE)serviceProvider.GetService(typeof(DTE));

                string[] values   = serializedData.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                webType  kind     = (webType)Enum.Parse(typeof(webType), values[0]);
                string   location = values[1];

                string uniqueName = location;

                if (kind == webType.webTypeFileSystem && !HasDriveSpecification(location))
                {
                    uniqueName = Path.GetDirectoryName(vs.Solution.FileName) + location;
                }

                Project project = DteHelper.FindProject(vs, delegate(Project p)
                {
                    return(string.Equals(p.UniqueName, uniqueName, StringComparison.OrdinalIgnoreCase));
                });

                return(project);
            }
コード例 #4
0
            public string GetAppliesTo(object target)
            {
                ProjectItem targetItem = target as ProjectItem;

                if (targetItem == null)
                {
                    throw new ArgumentException("target");
                }

                string itemPath = "";
                bool   found    = DteHelper.BuildPathFromCollection(targetItem.ContainingProject.ProjectItems, targetItem, ref itemPath);

                // This would indicate a bug in the DTE itself.
                Debug.Assert(found, "Item does not belong to containing project?");

                webType kind = (webType)targetItem.ContainingProject.Properties.Item("WebSiteType").Value;

                if (kind == webType.webTypeFileSystem)
                {
                    // Use the simplified representation of the path if available
                    if (targetItem.ContainingProject.ParentProjectItem != null)
                    {
                        itemPath = targetItem.ContainingProject.ParentProjectItem.Name + itemPath;
                    }
                    else
                    {
                        itemPath = targetItem.ContainingProject.Name + itemPath;
                    }
                }
                else
                {
                    itemPath = targetItem.ContainingProject.FullName +
                               itemPath.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
                }

                return(itemPath);
            }