Browse Source

Reverse Static Class icon changes to TypeTreeNode.cs

Commit:637a91236ce4a79ef0d0cc3227f77ae170eb98aa
Commit:e7caa3f43fa03c6480a76ba492eb7c53f858f617
pull/170/head
Ed Harvey 14 years ago
parent
commit
db114400ba
  1. 70
      ILSpy/TreeNodes/TypeTreeNode.cs

70
ILSpy/TreeNodes/TypeTreeNode.cs

@ -30,7 +30,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
{ {
readonly TypeDefinition type; readonly TypeDefinition type;
readonly AssemblyTreeNode parentAssemblyNode; readonly AssemblyTreeNode parentAssemblyNode;
public TypeTreeNode(TypeDefinition type, AssemblyTreeNode parentAssemblyNode) public TypeTreeNode(TypeDefinition type, AssemblyTreeNode parentAssemblyNode)
{ {
if (parentAssemblyNode == null) if (parentAssemblyNode == null)
@ -41,36 +41,29 @@ namespace ICSharpCode.ILSpy.TreeNodes
this.parentAssemblyNode = parentAssemblyNode; this.parentAssemblyNode = parentAssemblyNode;
this.LazyLoading = true; this.LazyLoading = true;
} }
public TypeDefinition TypeDefinition public TypeDefinition TypeDefinition {
{
get { return type; } get { return type; }
} }
public AssemblyTreeNode ParentAssemblyNode public AssemblyTreeNode ParentAssemblyNode {
{
get { return parentAssemblyNode; } get { return parentAssemblyNode; }
} }
public string Name public string Name {
{
get { return type.Name; } get { return type.Name; }
} }
public string Namespace public string Namespace {
{
get { return type.Namespace; } get { return type.Namespace; }
} }
public override object Text public override object Text {
{
get { return HighlightSearchMatch(this.Language.TypeToString(type, includeNamespace: false)); } get { return HighlightSearchMatch(this.Language.TypeToString(type, includeNamespace: false)); }
} }
public bool IsPublicAPI public bool IsPublicAPI {
{ get {
get
{
switch (type.Attributes & TypeAttributes.VisibilityMask) { switch (type.Attributes & TypeAttributes.VisibilityMask) {
case TypeAttributes.Public: case TypeAttributes.Public:
case TypeAttributes.NestedPublic: case TypeAttributes.NestedPublic:
@ -82,7 +75,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
} }
} }
} }
public override FilterResult Filter(FilterSettings settings) public override FilterResult Filter(FilterSettings settings)
{ {
if (!settings.ShowInternalApi && !IsPublicAPI) if (!settings.ShowInternalApi && !IsPublicAPI)
@ -96,7 +89,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
return FilterResult.Recurse; return FilterResult.Recurse;
} }
} }
protected override void LoadChildren() protected override void LoadChildren()
{ {
if (type.BaseType != null || type.HasInterfaces) if (type.BaseType != null || type.HasInterfaces)
@ -109,7 +102,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
foreach (FieldDefinition field in type.Fields.OrderBy(m => m.Name)) { foreach (FieldDefinition field in type.Fields.OrderBy(m => m.Name)) {
this.Children.Add(new FieldTreeNode(field)); this.Children.Add(new FieldTreeNode(field));
} }
foreach (PropertyDefinition property in type.Properties.OrderBy(m => m.Name)) { foreach (PropertyDefinition property in type.Properties.OrderBy(m => m.Name)) {
this.Children.Add(new PropertyTreeNode(property)); this.Children.Add(new PropertyTreeNode(property));
} }
@ -123,7 +116,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
} }
} }
} }
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options) public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{ {
language.DecompileType(type, output, options); language.DecompileType(type, output, options);
@ -153,10 +146,8 @@ namespace ICSharpCode.ILSpy.TreeNodes
} else { } else {
if (type.IsInterface) if (type.IsInterface)
return TypeIcon.Interface; return TypeIcon.Interface;
else if (IsDelegate(type)) else if (type.BaseType != null && type.BaseType.FullName == typeof(MulticastDelegate).FullName)
return TypeIcon.Delegate; return TypeIcon.Delegate;
else if (IsStaticClass(type))
return TypeIcon.StaticClass;
else else
return TypeIcon.Class; return TypeIcon.Class;
} }
@ -187,28 +178,9 @@ namespace ICSharpCode.ILSpy.TreeNodes
} }
return overlay; return overlay;
} }
private static bool IsDelegate(TypeDefinition type)
{
return type.BaseType != null && type.BaseType.FullName == typeof(MulticastDelegate).FullName;
}
private static bool IsStaticClass(TypeDefinition type)
{
if (type.IsSealed) {
if (type.IsAbstract)
return true;
else
return !type.Methods.Where(m => m.Name == ".ctor").Any(m => !m.IsPrivate);
}
return false;
}
#endregion #endregion
MemberReference IMemberTreeNode.Member MemberReference IMemberTreeNode.Member {
{
get { return type; } get { return type; }
} }
} }

Loading…
Cancel
Save