本文整理汇总了C#中IMenuItemContext.Find方法的典型用法代码示例。如果您正苦于以下问题:C# IMenuItemContext.Find方法的具体用法?C# IMenuItemContext.Find怎么用?C# IMenuItemContext.Find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMenuItemContext
的用法示例。
在下文中一共展示了IMenuItemContext.Find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetStatements
public static IList<MethodSourceStatement> GetStatements(IMenuItemContext context) {
if (context == null)
return null;
if (context.CreatorObject.Guid != new Guid(MenuConstants.GUIDOBJ_DOCUMENTVIEWERCONTROL_GUID))
return null;
var uiContext = context.Find<IDocumentViewer>();
if (uiContext == null)
return null;
var pos = context.Find<TextEditorPosition>();
if (pos == null)
return null;
return GetStatements(uiContext, pos.Position);
}
示例2: IsVisible
public override bool IsVisible(IMenuItemContext context)
{
if (context.CreatorObject.Guid != new Guid(MenuConstants.GUIDOBJ_TEXTEDITORCONTROL_GUID))
return false;
var uiContext = context.Find<ITextEditorUIContext>();
return uiContext != null && uiContext.HasSelectedText;
}
示例3: GetEntryPoint
static MethodDef GetEntryPoint(IMenuItemContext context) {
if (context.CreatorObject.Guid != new Guid(MenuConstants.GUIDOBJ_DOCUMENTS_TREEVIEW_GUID))
return null;
var nodes = context.Find<TreeNodeData[]>();
var node = nodes == null || nodes.Length == 0 ? null : nodes[0];
var module = node.GetModule();
return module == null ? null : module.EntryPoint as MethodDef;
}
示例4: IsVisible
public override bool IsVisible(IMenuItemContext context) {
if (context.CreatorObject.Guid != new Guid(MenuConstants.GUIDOBJ_DOCUMENTVIEWERCONTROL_GUID))
return false;
var uiContext = context.Find<IDocumentViewer>();
if (uiContext == null)
return false;
var nodes = uiContext.DocumentTab.Content.Nodes.ToArray();
return nodes.Length == 1 && nodes[0] is BamlResourceElementNode;
}
示例5: IsVisible
public override bool IsVisible(IMenuItemContext context) {
if (context.CreatorObject.Guid != new Guid(MenuConstants.GUIDOBJ_TEXTEDITORCONTROL_GUID))
return false;
var uiContext = context.Find<ITextEditorUIContext>();
if (uiContext == null)
return false;
var nodes = uiContext.FileTab.Content.Nodes.ToArray();
return nodes.Length == 1 && nodes[0] is BamlResourceElementNode;
}
示例6: GetReference
internal static uint? GetReference(IMenuItemContext context, string guid) {
if (context.CreatorObject.Guid != new Guid(guid))
return null;
var @ref = context.Find<CodeReference>();
if (@ref != null && @ref.Reference is IMDTokenProvider)
return ((IMDTokenProvider)@ref.Reference).MDToken.Raw;
if (@ref != null && @ref.Reference is TokenReference)
return ((TokenReference)@ref.Reference).Token;
return null;
}
示例7: Execute
public override void Execute(IMenuItemContext context) {
if (context.CreatorObject.Guid != new Guid(MenuConstants.GUIDOBJ_DOCUMENTS_TREEVIEW_GUID))
return;
var asms = new List<IDsDocument>();
foreach (var node in (context.Find<TreeNodeData[]>() ?? Array.Empty<TreeNodeData>())) {
var file = GetDocument(node);
if (file != null)
asms.Add(file);
}
foreach (var asm in asms) {
var peImage = asm.PEImage;
if (peImage != null)
peImage.UnsafeDisableMemoryMappedIO();
}
}
示例8: Execute
public override void Execute(IMenuItemContext context) {
if (context.CreatorObject.Guid != new Guid(MenuConstants.GUIDOBJ_FILES_TREEVIEW_GUID))
return;
var asms = new List<IDnSpyFile>();
foreach (var node in (context.Find<ITreeNodeData[]>() ?? new ITreeNodeData[0])) {
var file = GetDnSpyFile(node);
if (file != null)
asms.Add(file);
}
foreach (var asm in asms) {
var peImage = asm.PEImage;
if (peImage != null)
peImage.UnsafeDisableMemoryMappedIO();
}
}
示例9: GetReference
TreeNodeData GetReference(IMenuItemContext context) {
if (context.CreatorObject.Guid != new Guid(MenuConstants.GUIDOBJ_ANALYZER_TREEVIEW_GUID))
return null;
var nodes = context.Find<TreeNodeData[]>();
if (nodes == null || nodes.Length != 1)
return null;
var tokenNode = nodes[0] as IMDTokenNode;
if (tokenNode != null && tokenNode.Reference != null) {
if (!analyzerService.Value.CanFollowNode(nodes[0], useCodeRef))
return null;
return nodes[0];
}
return null;
}
示例10: GetNodes
internal static IEnumerable<TreeNodeData> GetNodes(IMenuItemContext context, string guid) {
if (context.CreatorObject.Guid != new Guid(guid))
yield break;
var nodes = context.Find<TreeNodeData[]>();
if (nodes == null)
yield break;
foreach (var node in nodes) {
var tokNode = node as IMDTokenNode;
if (tokNode != null) {
if (IsPublic(tokNode.Reference as IMemberRef))
yield return node;
continue;
}
var nsNode = node as NamespaceNode;
if (nsNode != null) {
if (!string.IsNullOrEmpty(nsNode.Name))
yield return node;
continue;
}
}
}
示例11: GetFilename
static string GetFilename(IMenuItemContext context) {
if (context.CreatorObject.Guid != new Guid(MenuConstants.GUIDOBJ_DOCUMENTS_TREEVIEW_GUID))
return null;
var nodes = context.Find<TreeNodeData[]>();
if (nodes?.Length != 1)
return null;
var documentNode = nodes[0] as DsDocumentNode;
var filename = documentNode?.Document?.Filename;
if (!File.Exists(filename))
return null;
return filename;
}
示例12: GetMemberRefs
internal static IEnumerable<IMemberRef> GetMemberRefs(IMenuItemContext context, string guid, bool checkRoot, ILanguageManager languageManager) {
if (context.CreatorObject.Guid != new Guid(guid))
yield break;
var nodes = context.Find<ITreeNodeData[]>();
if (nodes == null)
yield break;
if (checkRoot && nodes.All(a => a.TreeNode.Parent != null && a.TreeNode.Parent.Parent == null))
yield break;
foreach (var node in nodes) {
var mr = node as IMDTokenNode;
if (mr != null && CanAnalyze(mr.Reference as IMemberRef, languageManager.SelectedLanguage))
yield return mr.Reference as IMemberRef;
}
}
示例13: TryCreate
static ResourceRef TryCreate(IMenuItemContext context)
{
if (context.CreatorObject.Guid != new Guid(MenuConstants.GUIDOBJ_TEXTEDITORCONTROL_GUID))
return null;
return TryCreate(context.Find<CodeReference>());
}
示例14: GetUIContext
ITextEditorUIContext GetUIContext(IMenuItemContext context) {
// Only show this in the text editor
if (context.CreatorObject.Guid != new Guid(MenuConstants.GUIDOBJ_TEXTEDITORCONTROL_GUID))
return null;
return context.Find<ITextEditorUIContext>();
}
示例15: IsVisible
public override bool IsVisible(IMenuItemContext context) {
if (context.CreatorObject.Guid != new Guid(MenuConstants.GUIDOBJ_TEXTEDITORCONTROL_GUID))
return false;
return CanExecute(context.Find<ITextEditorUIContext>());
}