Beispiel #1
0
		TypeNode ReadType(ITypeDefinition type)
		{
			var asm = GetOrCreateAssembly(type.ParentAssembly);
			var ns = GetOrCreateNamespace(asm, type.Namespace);
			TypeNode parent;
			var node = new TypeNode(type);
			if (type.DeclaringTypeDefinition != null) {
				if (typeMappings.TryGetValue(type.DeclaringTypeDefinition, out parent))
					parent.AddChild(node);
				else
					throw new Exception("TypeNode not found: " + type.DeclaringTypeDefinition.FullName);
			} else
				ns.AddChild(node);
			cecilMappings[loader.GetCecilObject(type.Parts.First())] = type;
			typeMappings.Add(type, node);
			return node;
		}
		public static BitmapSource GetIcon(TypeNode type)
		{
			switch (type.TypeDefinition.Kind) {
				case TypeKind.Enum:
					if (type.TypeDefinition.IsPublic)
						return Enum;
					if (type.TypeDefinition.IsProtected)
						return ProtectedEnum;
					if (type.TypeDefinition.IsInternal)
						return InternalEnum;
					return PrivateEnum;
				case TypeKind.Struct:
					if (type.TypeDefinition.IsPublic)
						return Struct;
					if (type.TypeDefinition.IsProtected)
						return ProtectedStruct;
					if (type.TypeDefinition.IsInternal)
						return InternalStruct;
					return PrivateStruct;
				case TypeKind.Interface:
					if (type.TypeDefinition.IsPublic)
						return Interface;
					if (type.TypeDefinition.IsProtected)
						return ProtectedInterface;
					if (type.TypeDefinition.IsInternal)
						return InternalInterface;
					return PrivateInterface;
				case TypeKind.Delegate:
					if (type.TypeDefinition.IsPublic)
						return Delegate;
					if (type.TypeDefinition.IsProtected)
						return ProtectedDelegate;
					if (type.TypeDefinition.IsInternal)
						return InternalDelegate;
					return PrivateDelegate;
				default:
					if (type.TypeDefinition.IsPublic)
						return Class;
					if (type.TypeDefinition.IsProtected)
						return ProtectedClass;
					if (type.TypeDefinition.IsInternal)
						return InternalClass;
					return PrivateClass;
			}
		}