本文整理汇总了C#中IProjectService.GetProjectItem方法的典型用法代码示例。如果您正苦于以下问题:C# IProjectService.GetProjectItem方法的具体用法?C# IProjectService.GetProjectItem怎么用?C# IProjectService.GetProjectItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProjectService
的用法示例。
在下文中一共展示了IProjectService.GetProjectItem方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RequestBootstrapFile
/// <summary>
/// Requests the bootstrap file.
/// </summary>
/// <param name="projectService">The project service.</param>
/// <param name="plugin">The plugin.</param>
internal void RequestBootstrapFile(
IProjectService projectService,
Plugin plugin)
{
TraceService.WriteLine("PluginService::RequestBootstrapFile plugin=" + plugin.FriendlyName);
string bootstrapFileName = plugin.FriendlyName + "PluginBootstrap.cs";
//// check if the file already exists
IProjectItemService projectItemService = projectService.GetProjectItem(bootstrapFileName);
if (projectItemService == null)
{
//// get the currently requested plugins.
string currentPlugins = this.settingsService.PluginsToAdd;
string newPlugins = currentPlugins + "+" + bootstrapFileName;
//// and now save the new requested plugins.
this.settingsService.PluginsToAdd = newPlugins;
TraceService.WriteLine("***plugins for" + projectService.Name + " " + newPlugins);
}
}
示例2: AddConverter
/// <summary>
/// Adds the converter.
/// </summary>
/// <param name="projectService">The project service.</param>
/// <param name="templatesPath">The templates path.</param>
/// <param name="messages">The messages.</param>
/// <param name="templateInfo">The template info.</param>
internal void AddConverter(
IProjectService projectService,
string templatesPath,
List<string> messages,
ItemTemplateInfo templateInfo)
{
TraceService.WriteLine("ConvertersService::AddConverters adding from template path " + templatesPath + " template=" + templateInfo.FileName);
string fileName = templateInfo.FriendlyName + ".cs";
projectService.AddToFolderFromTemplate("Converters", templateInfo.FileName, fileName, false);
IProjectItemService projectItemService = projectService.GetProjectItem(fileName);
//// if we find the project item replace the text in it.
if (projectItemService != null)
{
projectItemService.ReplacePattern("MvvmCross." + templateInfo.FriendlyName, projectService.Name);
projectItemService.Save();
}
messages.Add(@"Converters\" + fileName + " added to project " + projectService.Name + ".");
}
示例3: AddToViewModel
/// <summary>
/// Adds to view model.
/// </summary>
/// <param name="visualStudioService">The visual studio service.</param>
/// <param name="viewModelName">Name of the view model.</param>
/// <param name="createUnitTests">if set to <c>true</c> [create unit tests].</param>
/// <param name="coreProjectService">The core project service.</param>
/// <param name="enumerablePlugins">The enumerable plugins.</param>
internal void AddToViewModel(
IVisualStudioService visualStudioService,
string viewModelName,
bool createUnitTests,
IProjectService coreProjectService,
IEnumerable<Plugin> enumerablePlugins)
{
TraceService.WriteLine("PluginsService::AddToViewModel viewModelName=" + viewModelName);
IProjectItemService testProjectItemService = null;
IProjectItemService projectItemService = coreProjectService.GetProjectItem(viewModelName);
if (projectItemService.ProjectItem != null)
{
foreach (Plugin plugin in enumerablePlugins)
{
testProjectItemService = this.CreateSnippet(
visualStudioService,
viewModelName,
createUnitTests,
coreProjectService.Name,
projectItemService,
plugin);
}
if (this.settingsService.UseNugetForPlugins == false)
{
projectItemService.FixUsingStatements();
}
else
{
projectItemService.MoveUsingStatements();
}
projectItemService.RemoveDoubleBlankLines();
//// also only do once for the unit test file.
if (createUnitTests && testProjectItemService != null)
{
if (this.settingsService.UseNugetForPlugins == false)
{
testProjectItemService.FixUsingStatements();
}
else
{
testProjectItemService.MoveUsingStatements();
}
//// we may need to update the testing method attribute.
this.testingService.UpdateTestMethodAttribute(testProjectItemService);
}
}
}
示例4: AddServicesToViewModel
/// <summary>
/// Adds the services to view model.
/// </summary>
/// <param name="visualStudioService">The visual studio service.</param>
/// <param name="itemTemplateInfos">The item template infos.</param>
/// <param name="viewModelName">Name of the view model.</param>
/// <param name="createUnitTests">if set to <c>true</c> [create unit tests].</param>
/// <param name="coreProjectService">The core project service.</param>
internal void AddServicesToViewModel(
IVisualStudioService visualStudioService,
IEnumerable<ItemTemplateInfo> itemTemplateInfos,
string viewModelName,
bool createUnitTests,
IProjectService coreProjectService)
{
TraceService.WriteLine("ServicesService::AddServicesToViewModel");
IProjectItemService projectItemService = coreProjectService.GetProjectItem(viewModelName);
if (projectItemService != null)
{
itemTemplateInfos.ToList()
.ForEach(x => this.ImplementCodeSnippet(
visualStudioService,
viewModelName,
coreProjectService,
projectItemService,
x));
if (createUnitTests)
{
itemTemplateInfos.ToList()
.ForEach(x => this.ImplementTestCodeSnippet(
visualStudioService,
viewModelName,
x));
}
projectItemService.FixUsingStatements();
}
}
示例5: ReplaceProjectItemText
/// <summary>
/// Replaces the project item text.
/// </summary>
/// <param name="projectService">The project service.</param>
/// <param name="projectItem">The project item.</param>
/// <param name="text">The text.</param>
/// <param name="replacementText">The replacement text.</param>
internal void ReplaceProjectItemText(
IProjectService projectService,
string projectItem,
string text,
string replacementText)
{
if (projectService != null)
{
IProjectItemService projectItemService = projectService.GetProjectItem(projectItem);
if (projectItemService != null)
{
projectItemService.ReplaceText(text, replacementText);
}
}
}
示例6: CreateUnitTests
/// <summary>
/// Creates the unit tests.
/// </summary>
/// <param name="visualStudioService">The visual studio service.</param>
/// <param name="projectService">The project service.</param>
/// <param name="codeSnippetsPath">The code snippets path.</param>
/// <param name="viewModelName">Name of the view model.</param>
/// <param name="friendlyName">Name of the friendly.</param>
/// <param name="usingStatement">The using statement.</param>
/// <returns>The project item service.</returns>
public IProjectItemService CreateUnitTests(
IVisualStudioService visualStudioService,
IProjectService projectService,
string codeSnippetsPath,
string viewModelName,
string friendlyName,
string usingStatement)
{
TraceService.WriteLine("SnippetService::CreateUnitTests viewModelName=" + viewModelName);
CodeSnippet codeSnippet = this.GetUnitTestingSnippet(codeSnippetsPath);
if (codeSnippet != null)
{
if (string.IsNullOrEmpty(usingStatement) == false)
{
if (codeSnippet.UsingStatements == null)
{
codeSnippet.UsingStatements = new List<string>();
}
codeSnippet.UsingStatements.Add(usingStatement);
}
if (this.settingsService.ReplaceVariablesInSnippets)
{
this.ApplyGlobals(visualStudioService, codeSnippet);
}
string fileName = "Test" + viewModelName;
//// are we going to assume that the TestViewModel source file already exists?
IProjectItemService projectItemService = projectService.GetProjectItem(fileName);
if (projectItemService != null)
{
projectItemService.ImplementUnitTestingCodeSnippet(
codeSnippet,
viewModelName,
this.settingsService.RemoveDefaultFileHeaders,
this.settingsService.RemoveDefaultComments,
this.settingsService.FormatFunctionParameters);
this.Messages.Add(friendlyName + " test code added to " + fileName + ".cs in project " + projectService.Name + ".");
return projectItemService;
}
}
else
{
TraceService.WriteError("SnippetService::CreateUnitTests File Not Found=" + codeSnippetsPath);
}
return null;
}
示例7: GetFileItems
/// <summary>
/// Gets the file items.
/// </summary>
/// <param name="fileOperation">The file operation.</param>
/// <param name="projectService">The project service.</param>
/// <returns>The files to have operations on.</returns>
private IEnumerable<IProjectItemService> GetFileItems(
FileOperation fileOperation,
IProjectService projectService)
{
TraceService.WriteLine("FileOperationService::GetFileItems");
List<IProjectItemService> fileItemServices = new List<IProjectItemService>();
if (string.IsNullOrEmpty(fileOperation.Directory) == false)
{
IProjectItemService projectItemService = projectService.GetFolder(fileOperation.Directory);
if (projectItemService != null)
{
if (string.IsNullOrEmpty(fileOperation.File) == false)
{
fileItemServices.Add(projectItemService.GetProjectItem(fileOperation.File));
}
else
{
IEnumerable<IProjectItemService> projectItemServices = projectItemService.GetCSharpProjectItems();
foreach (IProjectItemService childProjectItemService in projectItemServices)
{
TraceService.WriteDebugLine("FileOperationService::GetFileItems File=" + childProjectItemService.Name);
fileItemServices.Add(childProjectItemService);
}
}
}
else
{
TraceService.WriteDebugLine("Directory " + fileOperation.Directory + " not found");
}
}
else
{
fileItemServices.Add(projectService.GetProjectItem(fileOperation.File));
}
TraceService.WriteDebugLine("FileOperationService::GetFileItems fileItemServicesCount=" + fileItemServices.Count);
return fileItemServices;
}
示例8: AddServicesToViewModel
/// <summary>
/// Adds the services to view model.
/// </summary>
/// <param name="visualStudioService">The visual studio service.</param>
/// <param name="itemTemplateInfos">The item template infos.</param>
/// <param name="viewModelName">Name of the view model.</param>
/// <param name="createUnitTests">if set to <c>true</c> [create unit tests].</param>
/// <param name="coreProjectService">The core project service.</param>
internal void AddServicesToViewModel(
IVisualStudioService visualStudioService,
IEnumerable<ItemTemplateInfo> itemTemplateInfos,
string viewModelName,
bool createUnitTests,
IProjectService coreProjectService)
{
TraceService.WriteLine("ServicesService::AddServicesToViewModel");
IProjectItemService testProjectItemService = null;
IProjectItemService projectItemService = coreProjectService.GetProjectItem(viewModelName);
if (projectItemService.ProjectItem != null)
{
foreach (ItemTemplateInfo itemTemplateInfo in itemTemplateInfos)
{
testProjectItemService = this.CreateSnippet(
visualStudioService,
viewModelName,
this.settingsService.CodeSnippetsPath + @"\Services",
createUnitTests,
coreProjectService,
projectItemService,
itemTemplateInfo);
}
projectItemService.FixUsingStatements();
//// also only do once for the unit test file.
if (createUnitTests && testProjectItemService != null)
{
testProjectItemService.FixUsingStatements();
}
}
}
示例9: RequestBootstrapFile
/// <summary>
/// Requests the bootstrap file.
/// </summary>
/// <param name="projectService">The project service.</param>
/// <param name="friendlyName">Name of the friendly.</param>
internal void RequestBootstrapFile(
IProjectService projectService,
string friendlyName)
{
TraceService.WriteLine("PluginService::RequestBootstrapFile name=" + friendlyName);
CodeConfig codeConfig = this.codeConfigService.GetCodeConfig(projectService, friendlyName, false);
string bootstrapFileName = this.codeConfigService.GetBootstrapFileName(codeConfig, friendlyName);
//// check if the file already exists
IProjectItemService projectItemService = projectService.GetProjectItem(bootstrapFileName);
if (projectItemService == null)
{
//// get the currently requested plugins.
string currentPlugins = this.settingsService.PluginsToAdd;
string newPlugins = currentPlugins + "+" + bootstrapFileName;
//// and now save the new requested plugins.
this.settingsService.PluginsToAdd = newPlugins;
TraceService.WriteLine("***plugins for" + projectService.Name + " " + newPlugins);
}
}
示例10: BuildSourceFile
/// <summary>
/// Builds the source file.
/// </summary>
/// <param name="projectService">The project service.</param>
/// <param name="extensionSource">The extensionSource.</param>
/// <param name="extensionDestination">The extension destination.</param>
/// <param name="friendlyName">Name of the friendly.</param>
internal void BuildSourceFile(
IProjectService projectService,
string extensionSource,
string extensionDestination,
string friendlyName)
{
TraceService.WriteLine("PluginsService::BuildSourceFile " + friendlyName);
try
{
string message = string.Format("BuildSourceFile Project Name={0} friendlyName={1}", projectService.Name, friendlyName);
TraceService.WriteLine(message);
string sourceFile = friendlyName + "PluginBootstrap.cs";
//// now we need to sort out the item template!
projectService.AddToFolderFromTemplate("Bootstrap", "MvvmCross.Plugin.zip", sourceFile, false);
this.Messages.Add(string.Format(@"Bootstrap\{0} added to {1} project.", sourceFile, projectService.Name));
IProjectItemService projectItemService = projectService.GetProjectItem(sourceFile);
//// if we find the project item replace the text in it.
if (projectItemService.ProjectItem != null)
{
this.FixUpFile(projectService, friendlyName, projectItemService);
}
}
catch (Exception exception)
{
TraceService.WriteError("BuildSourceFile " + exception.Message);
}
}
示例11: AddToViewModel
/// <summary>
/// Adds to view model.
/// </summary>
/// <param name="visualStudioService">The visual studio service.</param>
/// <param name="viewModelName">Name of the view model.</param>
/// <param name="createUnitTests">if set to <c>true</c> [create unit tests].</param>
/// <param name="coreProjectService">The core project service.</param>
/// <param name="enumerablePlugins">The enumerable plugins.</param>
internal void AddToViewModel(
IVisualStudioService visualStudioService,
string viewModelName,
bool createUnitTests,
IProjectService coreProjectService,
Plugin[] enumerablePlugins)
{
TraceService.WriteLine("PluginsService::AddToViewModel viewModelName=" + viewModelName);
IProjectItemService testProjectItemService = null;
IProjectItemService projectItemService = coreProjectService.GetProjectItem(viewModelName);
if (projectItemService.ProjectItem != null)
{
foreach (Plugin plugin in enumerablePlugins)
{
testProjectItemService = this.CreateSnippet(
visualStudioService,
viewModelName,
this.SettingsService.CodeSnippetsPath + @"\Plugins",
createUnitTests,
coreProjectService.Name,
projectItemService,
plugin);
}
//// also only do once for the unit test file.
if (createUnitTests && testProjectItemService != null)
{
testProjectItemService.FixUsingStatements();
}
}
}