本文整理汇总了C#中ICSharpCode.ILSpy.TreeNodes.ILSpyTreeNode类的典型用法代码示例。如果您正苦于以下问题:C# ILSpyTreeNode类的具体用法?C# ILSpyTreeNode怎么用?C# ILSpyTreeNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ILSpyTreeNode类属于ICSharpCode.ILSpy.TreeNodes命名空间,在下文中一共展示了ILSpyTreeNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
protected override void Initialize(ILSpyTreeNode[] nodes, MenuItem menuItem)
{
if (nodes.Length == 1)
menuItem.Header = string.Format("Remove {0}", UIUtils.EscapeMenuItemHeader(nodes[0].ToString()));
else
menuItem.Header = string.Format("Remove {0} assemblies", nodes.Length);
}
示例2: Execute
internal static void Execute(ILSpyTreeNode[] nodes, uint[] offsets = null)
{
if (!CanExecute(nodes))
return;
var methodNode = (MethodTreeNode)nodes[0];
var module = ILSpyTreeNode.GetModule(nodes[0]);
Debug.Assert(module != null);
if (module == null)
throw new InvalidOperationException();
var data = new MethodBodyVM(new MethodBodyOptions(methodNode.MethodDefinition), module, MainWindow.Instance.CurrentLanguage, methodNode.MethodDefinition.DeclaringType, methodNode.MethodDefinition);
var win = new MethodBodyDlg();
win.DataContext = data;
win.Owner = MainWindow.Instance;
win.Title = string.Format("{0} - {1}", win.Title, methodNode.ToString());
if (data.IsCilBody && offsets != null)
data.CilBodyVM.Select(offsets);
if (win.ShowDialog() != true)
return;
UndoCommandManager.Instance.Add(new MethodBodySettingsCommand(methodNode, data.CreateMethodBodyOptions()));
}
示例3: SearchMsdn
public static void SearchMsdn(ILSpyTreeNode node)
{
var address = string.Empty;
var namespaceNode = node as NamespaceTreeNode;
if (namespaceNode != null)
address = string.Format(msdnAddress, namespaceNode.Name);
var memberNode = node as IMemberTreeNode;
if (memberNode != null)
{
var member = memberNode.Member;
var memberName = string.Empty;
if (member.DeclaringType == null)
memberName = member.FullName;
else
memberName = string.Format("{0}.{1}", member.DeclaringType.FullName, member.Name);
address = string.Format(msdnAddress, memberName);
}
address = address.ToLower();
if (!string.IsNullOrEmpty(address))
Process.Start(address);
}
示例4: Execute
static void Execute(ILSpyTreeNode[] nodes)
{
if (!AddNetModuleToAssemblyCommand.CanExecute(nodes))
return;
var dialog = new System.Windows.Forms.OpenFileDialog() {
Filter = ".NET NetModules (*.netmodule)|*.netmodule|All files (*.*)|*.*",
RestoreDirectory = true,
};
if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
return;
if (string.IsNullOrEmpty(dialog.FileName))
return;
var asm = new LoadedAssembly(MainWindow.Instance.CurrentAssemblyList, dialog.FileName);
if (asm.ModuleDefinition == null || asm.AssemblyDefinition != null) {
MainWindow.Instance.ShowMessageBox(string.Format("{0} is not a NetModule", asm.FileName), System.Windows.MessageBoxButton.OK);
asm.TheLoadedFile.Dispose();
return;
}
var cmd = new AddExistingNetModuleToAssemblyCommand((AssemblyTreeNode)nodes[0], asm);
UndoCommandManager.Instance.Add(cmd);
MainWindow.Instance.JumpToReference(cmd.modNode);
}
示例5:
SharpTreeNode IRenamerContextMenu.FindRenamedNode(ILSpyTreeNode oldNode, string[] path, string oldName, object targetObject)
{
var newName = RenameHelper.GetName(targetObject);
RenamePath(oldNode, path, oldName, newName);
return MainWindow.Instance.FindNodeByPath(path, true);
}
示例6: SearchMsdn
public static void SearchMsdn(ILSpyTreeNode node)
{
var address = string.Empty;
var namespaceNode = node as NamespaceTreeNode;
if (namespaceNode != null)
address = string.Format(msdnAddress, namespaceNode.Name);
var memberNode = node as IMemberTreeNode;
if (memberNode != null)
{
var member = memberNode.Member;
var memberName = string.Empty;
ITypeDefOrRef declType = null;
if (member is IDefinition)
declType = ((IDefinition)member).DeclaringType;
else if (declType is IField)
declType = ((IField)member).DeclaringType;
else if (declType is IMethod)
declType = ((IMethod)member).DeclaringType;
if (declType == null)
memberName = member.FullName;
else
memberName = string.Format("{0}.{1}", declType.FullName, member.Name);
address = string.Format(msdnAddress, memberName);
}
address = address.ToLower();
if (!string.IsNullOrEmpty(address))
Process.Start(address);
}
示例7: Execute
static void Execute(ILSpyTreeNode[] nodes) {
if (!CanExecute(nodes))
return;
var nsNodes = nodes.Select(a => (NamespaceTreeNode)a).ToArray();
UndoCommandManager.Instance.Add(new DeleteNamespaceCommand(nsNodes));
}
示例8: GetDnSpyFileList
static DnSpyFileList GetDnSpyFileList(ILSpyTreeNode node) {
if (node == null)
return null;
var asmNode = GetNode<AssemblyTreeNode>(node);
if (asmNode == null)
return null;
return asmNode.DnSpyFileList;
}
示例9: Execute
static void Execute(ILSpyTreeNode[] nodes) {
if (!CanExecute(nodes))
return;
var win = new NetModuleOptionsDlg();
var data = new NetModuleOptionsVM();
win.DataContext = data;
win.Owner = MainWindow.Instance;
if (win.ShowDialog() != true)
return;
var cmd = new CreateNetModuleCommand(data.CreateNetModuleOptions());
UndoCommandManager.Instance.Add(cmd);
MainWindow.Instance.JumpToReference(cmd.asmNodeCreator.AssemblyTreeNode);
}
示例10: RenamePath
private static void RenamePath(ILSpyTreeNode node, string[] path, string oldName, string newName)
{
if (node is TypeTreeNode)
{
string oldns;
TypeParts(oldName, out oldns, out oldName);
string newns;
TypeParts(newName, out newns, out newName);
if (path.Length > 1)
path[path.Length - 2] = path[path.Length - 2].Replace(oldns, newns);
}
if (path.Length > 0)
path[path.Length - 1] = path[path.Length - 1].Replace(oldName, newName);
}
示例11: PropertyTreeNode
public PropertyTreeNode(PropertyDef property, ILSpyTreeNode owner) {
if (property == null)
throw new ArgumentNullException("property");
this.property = property;
var list = GetDnSpyFileList(owner ?? this);
using (list == null ? null : list.DisableAssemblyLoad()) {
this.isIndexer = property.IsIndexer();
}
if (property.GetMethod != null)
this.Children.Add(new MethodTreeNode(property.GetMethod));
if (property.SetMethod != null)
this.Children.Add(new MethodTreeNode(property.SetMethod));
if (property.HasOtherMethods) {
foreach (var m in property.OtherMethods)
this.Children.Add(new MethodTreeNode(m));
}
}
示例12: GetAssemblyNodes
HashSet<IUndoObject> GetAssemblyNodes(ILSpyTreeNode[] nodes) {
var hash = new HashSet<IUndoObject>();
if (nodes.Length == 0) {
var hex = MainWindow.Instance.ActiveTabState as HexTabState;
if (hex != null) {
var doc = hex.HexBox.Document as AsmEdHexDocument;
if (doc != null)
hash.Add(UndoCommandManager.Instance.GetUndoObject(doc));
}
}
foreach (var node in nodes) {
var asmNode = ILSpyTreeNode.GetNode<AssemblyTreeNode>(node);
if (asmNode == null)
continue;
bool added = false;
if (asmNode.DnSpyFile.ModuleDef != null) {
var uo = UndoCommandManager.Instance.GetUndoObject(asmNode.DnSpyFile);
if (UndoCommandManager.Instance.IsModified(uo)) {
hash.Add(uo);
added = true;
}
}
var doc = HexDocumentManager.Instance.TryGet(asmNode.DnSpyFile.Filename);
if (doc != null) {
var uo = UndoCommandManager.Instance.GetUndoObject(doc);
if (UndoCommandManager.Instance.IsModified(uo)) {
hash.Add(uo);
added = true;
}
}
// If nothing was modified, just include the selected module
if (!added && asmNode.DnSpyFile.ModuleDef != null)
hash.Add(UndoCommandManager.Instance.GetUndoObject(asmNode.DnSpyFile));
}
return hash;
}
示例13:
SharpTreeNode IRenamerContextMenu.FindRenamedNode(ILSpyTreeNode oldNode, string[] path, string oldName, object targetObject)
{
// After renaming an assembly, ILSpy is still using the filename to display node text, even if assembly name changed
var newNode = MainWindow.Instance.FindNodeByPath(path, true);
if (newNode == null)
return null;
// Hack, so we have to change the shortname, without changing the filename, so that the user can reload the previous state
var adef = targetObject as AssemblyDefinition;
if (!(newNode is AssemblyTreeNode) || adef == null)
return newNode;
var la = (newNode as AssemblyTreeNode).LoadedAssembly;
var pInfo = la.GetType().GetField("shortName", BindingFlags.Instance | BindingFlags.NonPublic);
if (pInfo == null)
return newNode;
pInfo.SetValue(la, adef.Name.Name);
newNode.RaisePropertyChanged("Text");
return newNode;
}
示例14: InjectWindowViewModel
public InjectWindowViewModel(ILSpyTreeNode node, Window window, bool canInjectExisting)
{
//Stores the given parameters
_node = node;
_window = window;
InjectExistingEnabled = canInjectExisting;
//Loads the injectors
Injectors = GlobalContainer.Injectors.Where(x => x.CanInjectInNode(node)).ToArray();
//Writes data for the header
InjectInIcon = (ImageSource)node.Icon;
InjectInContent = node.Text;
//Finds the module
var moduleNode = Helpers.Tree.GetModuleNode(node);
DestinationModule = moduleNode == null ? null : moduleNode.Module;
//Finds the enclosing type (if any)
EnclosingType = Helpers.Tree.GetType(node);
//Prepares the filters for the inject existing part
if (canInjectExisting)
{
ExistingMemberFilter = node is ModuleTreeNode ? MemberFilters.Types : null;
ExistingSelectableMembers = node is ModuleTreeNode ? new[] { TokenType.TypeDef } : new[] { TokenType.TypeDef, TokenType.Field, TokenType.Property, TokenType.Method, TokenType.Event };
}
//Prepares the commands
_InjectCommand = new RelayCommand(InjectCommandImpl);
//Loads from the settings the values of the properties of the 'existing' part
var settings = GlobalContainer.InjectionSettings.Element("InjectExistingSettings");
ExistingPreview = bool.Parse(settings.Attribute("Preview").Value);
ExistingImportAsNestedTypesEnabled = !(node is ModuleTreeNode);
ExistingImportAsNestedTypes = ExistingImportAsNestedTypesEnabled && bool.Parse(settings.Attribute("ImportAsNestedTypes").Value);
}
示例15: Initialize
static void Initialize(ILSpyTreeNode[] nodes, MenuItem menuItem)
{
if (nodes.Length == 1)
menuItem.Header = string.Format("Delete {0}", UIUtils.EscapeMenuItemHeader(nodes[0].ToString()));
else
menuItem.Header = string.Format("Delete {0} properties", nodes.Length);
}