本文整理汇总了C#中SolutionFolder.AddFromTemplate方法的典型用法代码示例。如果您正苦于以下问题:C# SolutionFolder.AddFromTemplate方法的具体用法?C# SolutionFolder.AddFromTemplate怎么用?C# SolutionFolder.AddFromTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SolutionFolder
的用法示例。
在下文中一共展示了SolutionFolder.AddFromTemplate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NewTemplateItemInSolutionFolder
private static void NewTemplateItemInSolutionFolder(string path, string itemTypeName, Solution2 sln,
NewItemDynamicParameters p, SolutionFolder folder)
{
var destinationPath = Path.Combine(
Path.GetDirectoryName(sln.FullName),
path
);
try
{
var n = sln.GetProjectTemplate(itemTypeName, p.Category);
folder.AddFromTemplate(n, destinationPath, path);
}
catch (FileNotFoundException)
{
var n = sln.GetProjectItemTemplate(itemTypeName, p.Category);
folder.AddFromTemplate(n, destinationPath, path);
}
}
示例2: BuildThemeWithProject
/// <summary>
/// Builds a blank theme including a project file.
/// </summary>
/// <param name="themesFolder">The themes folder.</param>
/// <param name="vm">The vm.</param>
/// <param name="templates">The templates.</param>
/// <param name="themeType">Type of theme.</param>
private void BuildThemeWithProject(SolutionFolder themesFolder, ThemeViewModel vm, string templates, string themeType)
{
var solution = GetGlobalService(typeof(SVsSolution)) as IVsSolution;
var envsol = dte.Solution;
string solpath;
string solfile;
string soloptions;
solution.GetSolutionInfo(out solpath, out solfile, out soloptions);
var newDir = Path.Combine(solpath, "Orchard.Web", "Themes", vm.ThemeName);
var newproj = themesFolder.AddFromTemplate(Path.Combine(templates, themeType, vm.Version, themeType + ".csproj"), newDir, vm.ThemeName);
Insert(Path.Combine(newDir, vm.ThemeName + ".csproj"),
new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>("$$ModuleProjectGuid$$", Guid.NewGuid().ToString()),
new KeyValuePair<string, string>("$$ModuleName$$", vm.ThemeName)
});
// this does work...
newproj.Properties.Item("AssemblyName").Value = vm.ThemeName;
// need this as well because... I have no idea
newproj.Properties.Item("RootNamespace").Value = vm.ThemeName;
EditThemeFile(newDir, vm);
// isn't added to tfs for some reason...
if (vm.IncludeHelpFile)
newproj.ProjectItems.AddFromFile(templates + "\\ThemeHelp.md");
newproj.Save();
}