Ejemplo n.º 1
0
        private static async Task <string> ReplaceTokens(Project project, string name, string relative, string templateFile)
        {
            if (string.IsNullOrEmpty(templateFile))
            {
                return(templateFile);
            }

            string rootNs = project.GetRootNamespace();
            string ns     = string.IsNullOrEmpty(rootNs) ? "MyNamespace" : rootNs;

            if (!string.IsNullOrEmpty(relative))
            {
                ns += "." + ProjectHelpers.CleanNameSpace(relative);
            }

            using (var reader = new StreamReader(templateFile))
            {
                string content = await reader.ReadToEndAsync();

                return(content.Replace("{namespace}", ns)
                       .Replace("{itemname}", name.Replace("Tests", "")));
            }
        }