Exemplo n.º 1
0
        static Dictionary <string, string> GetParameters(Project project, MicrosoftTemplateEngineItemTemplate template, NewItemConfiguration config)
        {
            var parameters = new Dictionary <string, string> ();

            var model = (IStringTagModel)config;

            foreach (ITemplateParameter parameter in template.TemplateInfo.Parameters)
            {
                string parameterValue = (string)model.GetValue(parameter.Name);
                if (parameterValue != null)
                {
                    parameters [parameter.Name] = parameterValue;
                }
            }

            var dotNetProject = project as DotNetProject;

            if (dotNetProject != null)
            {
                string fileName = GetFullPathIncludingFileExtension(template, config);
                parameters ["namespace"] = dotNetProject.GetDefaultNamespace(fileName);
            }

            return(parameters);
        }
Exemplo n.º 2
0
        static string GetFullPathIncludingFileExtension(MicrosoftTemplateEngineItemTemplate template, NewItemConfiguration config)
        {
            string fileName = config.Name;

            if (StringComparer.OrdinalIgnoreCase.Equals(template.Language, "C#"))
            {
                fileName = Path.ChangeExtension(config.Name, ".cs");
            }
            return(Path.Combine(config.Directory, fileName));
        }