本文整理汇总了C#中IContext.ResolvePath方法的典型用法代码示例。如果您正苦于以下问题:C# IContext.ResolvePath方法的具体用法?C# IContext.ResolvePath怎么用?C# IContext.ResolvePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContext
的用法示例。
在下文中一共展示了IContext.ResolvePath方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: XmlConfigurationLoader
public XmlConfigurationLoader(IContext context, string filePath, List<ISettingValidator> validators,
Dictionary<string, Type> typeAliases)
: base(context, validators, typeAliases)
{
_filePath = context.ResolvePath(filePath);
InitialiseFileWatcher();
}
示例2: Load
public ApplicationMode Load (IContext context)
{
if (_stream != null)
return GetModeFromStream();
string filePath = context.ResolvePath ("~/" + _fileName);
if (!File.Exists (filePath))
return ApplicationMode.Auto;
using (StreamReader sr = new StreamReader (filePath))
{
return sr.ReadLine ().ToEnum(ApplicationMode.Auto);
}
}
示例3: ResolveProject
private Project ResolveProject(IContext context, string projectName)
{
Project project = null;
var nodeFactory = new SolutionProjectsNodeFactory(_references.DTE as DTE2);
project = nodeFactory.ResolveProjectFromName(projectName);
if (null != project)
{
return project;
}
ProjectNodeFactory projectNodeFactory =
context.ResolvePath(projectName) as ProjectNodeFactory;
if (null != projectNodeFactory)
{
project = projectNodeFactory.Project;
}
return project;
}
示例4: GetOrCreateCommand
internal static ShellCommand GetOrCreateCommand(IContext context, DTE2 dte, string caption,
object commandPathOrScript)
{
var stringValue = commandPathOrScript as string;
var script = commandPathOrScript as ScriptBlock;
ShellCommand cmd = null;
if (null != stringValue)
{
// locate an existing command by path
try
{
var command = context.ResolvePath(stringValue);
if (null != command)
{
var value = command.GetNodeValue();
if (null != value)
{
cmd = value.Item as ShellCommand;
}
}
}
catch
{
}
// locate an existing command by name
if (null == cmd)
{
var node = context.ResolvePath("dte:/commands");
var factories = node.Resolve(context, stringValue);
if (null != factories && factories.Any())
{
var value = factories.First().GetNodeValue();
if (null != value)
{
cmd = value.Item as ShellCommand;
}
}
}
// assume the string is script;
if (null == cmd)
{
script = ScriptBlock.Create(stringValue);
}
}
if (null == cmd && null != script)
{
var coll =
new CommandCollectionPathNodeFactory(dte.Commands as Commands2);
var pm = new CommandCollectionPathNodeFactory.NewItemDynamicParameters
{
Button = true,
Label = caption,
Supported = true,
Enabled = true
};
cmd =
coll.NewItem(
new Context(context, pm),
"anonymousCommand_" + Guid.NewGuid().ToString("N"),
null, script
).Item as ShellCommand;
}
return cmd;
}
示例5: GetDocumentFromSourcePath
private string GetDocumentFromSourcePath(IContext context, string sourcePath)
{
if (String.IsNullOrEmpty(sourcePath))
{
return null;
}
var paths = context.SessionState.Path.GetResolvedPSPathFromPSPath(sourcePath);
sourcePath = paths[0].Path;
var nodeFactory = context.ResolvePath(sourcePath);
var item = nodeFactory.GetNodeValue().Item;
var i = item as ShellProjectItem;
if (null != i)
{
return i.FileNames[0];
}
return sourcePath;
}
示例6: GetProjectFromSourcePath
private Project GetProjectFromSourcePath(IContext context, IVsSolution sln, string sourcePath)
{
if (String.IsNullOrEmpty(sourcePath))
{
return null;
}
var paths = context.SessionState.Path.GetResolvedPSPathFromPSPath(sourcePath);
sourcePath = paths[0].Path;
var nodeFactory = context.ResolvePath(sourcePath);
var item = nodeFactory.GetNodeValue().Item;
var p = item as ShellProject;
var i = item as ShellProjectItem;
if (null != p)
{
return p.Object as Project;
}
if (null != i)
{
return i.ContainingProject.AsProject();
}
return null;
}