public static InfoProjeto ProjectDetails(eProjeto project)
        {
            var layer     = Enum.GetName(typeof(eProjeto), project);
            var layerInfo = dte.Solution.Projects.Cast <Project>().FirstOrDefault(p => p.Name.Contains($".{layer}"));
            var info      = new InfoProjeto {
                Nome = layerInfo.Name, Diretorio = Path.GetDirectoryName(layerInfo.Properties.Item("FullPath").Value.ToString())
            };

            return(info);
        }
예제 #2
0
        public void VincularPartialClass(InfoProjeto infoProjeto, string nomeArquivo, string diretorioArquivo)
        {
            var    resourceName = ResourceNameTemplates + "Project.itemGroup.txt";
            string textoTratado;

            using (Stream stream = Assembly.GetManifestResourceStream(resourceName))
                using (StreamReader reader = new StreamReader(stream))
                {
                    textoTratado = reader.ReadToEnd()
                                   .Replace("{{name}}", nomeArquivo)
                                   .Replace("{{path}}", diretorioArquivo);
                }

            var arquivoProjeto  = $@"{infoProjeto.Diretorio}\{infoProjeto.Nome}.csproj";
            var conteudoArquivo = new List <string>(File.ReadAllLines(arquivoProjeto));
            int indice          = RetornarIndiceArquivo(conteudoArquivo, "</PropertyGroup>");

            conteudoArquivo.Insert(indice + 1, textoTratado);
            File.WriteAllLines(arquivoProjeto, conteudoArquivo);
        }