Exemplo n.º 1
0
        private IList <VirtualFileSystemPath> ReadIncludePaths()
        {
            string registryKey = _vsEnvironmentInformation.VisualStudioGlobalRegistryPath
                                 + @"_Config\TextTemplating\IncludeFolders\.tt";

            using (RegistryKey key = Registry.CurrentUser.OpenSubKey(registryKey)) {
                if (key == null)
                {
                    return(EmptyList <VirtualFileSystemPath> .InstanceList);
                }

                string[] valueNames = key.GetValueNames();
                if (valueNames.Length == 0)
                {
                    return(EmptyList <VirtualFileSystemPath> .InstanceList);
                }

                var paths = new List <VirtualFileSystemPath>(valueNames.Length);
                foreach (string valueName in valueNames)
                {
                    var value = key.GetValue(valueName) as string;
                    if (String.IsNullOrEmpty(value))
                    {
                        continue;
                    }

                    var path = VirtualFileSystemPath.TryParse(value, InteractionContext.SolutionContext);
                    if (!path.IsEmpty && path.IsAbsolute)
                    {
                        paths.Add(path);
                    }
                }
                return(paths);
            }
        }
Exemplo n.º 2
0
        public VirtualFileSystemPath TryResolveAbsolutePath()
        {
            string expanded = ResolvedPath;

            // search as absolute path
            var asAbsolutePath = VirtualFileSystemPath.TryParse(expanded, InteractionContext.SolutionContext);

            if (asAbsolutePath.IsAbsolute)
            {
                return(asAbsolutePath);
            }

            // search as relative path
            var asRelativePath = SourceFile.GetLocation().Directory.TryCombine(expanded);

            if (asRelativePath.IsAbsolute && asRelativePath.ExistsFile)
            {
                return(asRelativePath);
            }

            return(null);
        }