本文整理汇总了C#中ProjectItem.GetFullPath方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectItem.GetFullPath方法的具体用法?C# ProjectItem.GetFullPath怎么用?C# ProjectItem.GetFullPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProjectItem
的用法示例。
在下文中一共展示了ProjectItem.GetFullPath方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetProjectRelativePath
public static string GetProjectRelativePath(ProjectItem projectItem)
{
Project project = projectItem.ContainingProject;
string projRelativePath = null;
string rootProjectDir = project.GetFullPath();
rootProjectDir = EnsureTrailingBackSlash(rootProjectDir);
string fullPath = projectItem.GetFullPath();
if (!String.IsNullOrEmpty(rootProjectDir) && !String.IsNullOrEmpty(fullPath))
{
projRelativePath = MakeRelativePath(fullPath, rootProjectDir);
}
return projRelativePath;
}
示例2: Add
public void Add(ProjectItem item)
{
if (item == null)
{
throw new ArgumentNullException("item");
}
var path = item.GetFullPath();
var existing = Lookup(path);
if (existing == null)
{
this.files[MakeKey(path)] = item;
Logger.WriteLine($"{item.Name} was added to the cache");
}
}
示例3: OverwriteProjectItemTextContent
private void OverwriteProjectItemTextContent(ProjectItem item, string text)
{
var path = item.GetFullPath();
SolutionManager.EnsureCheckedOutIfExists(path);
_fileSystem.WriteAllText(path, text);
}
示例4: UpdateGeneratedDtos
private void UpdateGeneratedDtos(ProjectItem projectItem, INativeTypesHandler typesHandler)
{
OutputWindowWriter.Show();
OutputWindowWriter.ShowOutputPane(dte);
OutputWindowWriter.WriteLine("--- Updating ServiceStack Reference '" + projectItem.Name + "' ---");
string projectItemPath = projectItem.GetFullPath();
var selectedFiles = projectItem.DTE.SelectedItems.Cast<SelectedItem>().ToList();
bool isDtoSelected = false;
isDtoSelected = selectedFiles
.Any(item => item.Name.ToLowerInvariant()
.EndsWith(typesHandler.CodeFileExtension));
//Handle FSharp file extension name change for DTO files, eg .dto.fs to .dtos.fs
if (!isDtoSelected && typesHandler is FSharpNativeTypesHandler)
{
isDtoSelected = selectedFiles
.Any(item => item.Name.ToLowerInvariant()
.EndsWith(".dto.fs"));
}
if (isDtoSelected)
{
string filePath = projectItemPath;
var existingGeneratedCode = File.ReadAllLines(filePath).Join(Environment.NewLine);
string baseUrl;
if (!typesHandler.TryExtractBaseUrl(existingGeneratedCode, out baseUrl))
{
OutputWindowWriter.WriteLine("Unable to read URL from DTO file. Please ensure the file was generated correctly from a ServiceStack server.");
return;
}
try
{
var options = typesHandler.ParseComments(existingGeneratedCode);
bool setSslValidationCallback = false;
//Don't set validation callback if one has already been set for VS.
if (ServicePointManager.ServerCertificateValidationCallback == null)
{
//Temp set validation callback to return true to avoid common dev server ssl certificate validation issues.
setSslValidationCallback = true;
ServicePointManager.ServerCertificateValidationCallback =
(sender, certificate, chain, errors) => true;
}
string updatedCode = typesHandler.GetUpdatedCode(baseUrl, options);
if (setSslValidationCallback)
{
//If callback was set to return true, reset back to null.
ServicePointManager.ServerCertificateValidationCallback = null;
}
using (var streamWriter = File.CreateText(filePath))
{
streamWriter.Write(updatedCode);
streamWriter.Flush();
}
}
catch (Exception e)
{
OutputWindowWriter.WriteLine("Failed to update ServiceStack Reference: Unhandled error - " + e.Message);
}
OutputWindowWriter.WriteLine("--- Update ServiceStack Reference Complete ---");
}
else
{
OutputWindowWriter.WriteLine("--- Valid file not found ServiceStack Reference '" + projectItem.Name + "' ---");
}
}
示例5: Remove
public void Remove(ProjectItem projectItem)
{
this.Remove(projectItem.GetFullPath());
}
示例6: GenerateJsFileFromProjectItem
private ViewModel GenerateJsFileFromProjectItem(ProjectItem item, bool fromCodeSnippet)
{
var fileExtension = Path.GetExtension(item.GetFullPath());
var language = fileExtension.Equals(".cs") ? SupportedLanguage.CSharp : SupportedLanguage.VBNet;
if (!item.Saved)
item.Save();
try
{
JsFile jsFile;
if (fromCodeSnippet)
{
dynamic comObject = item.Document.Selection;
jsFile = _codeGenerator.GetJsFileFromCodeSnippet(comObject.Text, language);
}
else
{
jsFile = _codeGenerator.GetJsFileFromCodeFile(item.GetFullPath(), language);
}
return ViewModelExtensions.MapViewModelFromJsFile(jsFile);
}
catch (Exception)
{
_schell.Toast("Error parsing file");
}
return null;
}
示例7: FindProjectItemByFullPath
private static ProjectItem FindProjectItemByFullPath(ProjectItem projectItem, string fullPath)
{
if (projectItem != null && projectItem.GetFullPath() == fullPath)
return projectItem;
foreach (ProjectItem childItem in projectItem.ProjectItems)
{
var re = FindProjectItemByFullPath(childItem, fullPath);
if (re != null)
return re;
}
return null;
}