/// <summary> /// Builds the URI for the given template based on the containing project VSIX manifest identifier. /// </summary> internal static Uri BuildUri(IItemContainer selectedItem) { var manifest = selectedItem.GetToolkitManifest(); var owningProject = selectedItem.Traverse(x => x.Parent, item => item.Kind == ItemKind.Project); tracer.Info(Properties.Resources.TextTemplateUriEditor_TraceReadingManifest, manifest.GetLogicalPath()); string vsixId; try { vsixId = Vsix.ReadManifestIdentifier(manifest.PhysicalPath); } catch (Exception e) { tracer.Error(e, String.Format(CultureInfo.CurrentCulture, Properties.Resources.TextTemplateUriEditor_TraceReadingManifestFailed, manifest.GetLogicalPath())); throw; } var path = GetLogicalPath(selectedItem).Replace(owningProject.GetLogicalPath(), string.Empty); // Use alternative name if IncludeInVSIXAs defined var templateItem = (IItem)selectedItem; if (IsIncludeInVSIXAs(templateItem)) { path = Path.Combine(Path.GetDirectoryName(path), templateItem.Data.IncludeInVSIXAs); } return(new Uri(new Uri(TextTemplateUri.UriHostPrefix), new Uri(vsixId + path, UriKind.Relative))); }
/// <summary> /// Builds the URI for the given template based on the containing project VSIX manifest identifier. /// </summary> internal static Uri BuildUri(IItemContainer selectedItem) { var manifest = selectedItem.GetToolkitManifest(); var owningProject = selectedItem.Traverse(x => x.Parent, item => item.Kind == ItemKind.Project); tracer.Info(Properties.Resources.TextTemplateUriEditor_TraceReadingManifest, manifest.GetLogicalPath()); string vsixId; try { vsixId = Vsix.ReadManifestIdentifier(manifest.PhysicalPath); } catch (Exception e) { tracer.Error(e, String.Format(CultureInfo.CurrentCulture, Properties.Resources.TextTemplateUriEditor_TraceReadingManifestFailed, manifest.GetLogicalPath())); throw; } var path = GetLogicalPath(selectedItem).Replace(owningProject.GetLogicalPath(), string.Empty); // Use alternative name if IncludeInVSIXAs defined var templateItem = (IItem)selectedItem; if (IsIncludeInVSIXAs(templateItem)) { path = Path.Combine(Path.GetDirectoryName(path), templateItem.Data.IncludeInVSIXAs); } return new Uri(new Uri(TextTemplateUri.UriHostPrefix), new Uri(vsixId + path, UriKind.Relative)); }