/// <summary></summary> public DotNetBaseType(Type type) { Name = DotNetQualifiedName.FromAssemblyInfo(type); if (type.BaseType != null) { BaseType = new DotNetBaseType(type.BaseType); } }
/// <summary> /// Load additional information from the assembly for this type. /// </summary> private void AddAssemblyInfo(Type type) { if (type.Attributes.IsAbstract()) { Category = TypeCategory.Abstract; } if (type.Attributes.IsStatic()) { Category = TypeCategory.Static; } if (type.Attributes.IsInterface()) { Category = TypeCategory.Interface; } if (type.IsEnum()) { Category = TypeCategory.Enum; } if (type.IsException()) { Category = TypeCategory.Exception; } if (type.IsValueType && !type.IsEnum()) { Category = TypeCategory.Struct; } if (Category == TypeCategory.Unknown) { Category = TypeCategory.Normal; } IsSealed = type.IsSealed; ClassName.AddAssemblyInfo(type); if (type.BaseType != null) { BaseType = new DotNetBaseType(type.BaseType); } Type[] implementedInterfaces = type.GetInterfaces(); if (implementedInterfaces != null) { foreach (Type interfaceType in implementedInterfaces) { ImplementedInterfaces.Add(new DotNetBaseType(interfaceType)); } } foreach (FieldInfo fieldInfo in type.GetDeclaredFields()) { DotNetField field = Fields.FirstOrDefault(f => fieldInfo.Name == f.Name.LocalName); if (field == null) { continue; } field.AddAssemblyInfo(fieldInfo); } foreach (PropertyInfo propertyInfo in type.GetDeclaredProperties().Where(x => x.GetGetMethod() == null || x.GetGetMethod().GetParameters().Count() == 0)) { DotNetProperty property = Properties.FirstOrDefault(p => propertyInfo.Name == DotNetQualifiedName.Combine(p.Name.ExplicitInterface, p.Name.LocalName)); if (property == null) { continue; } property.AddAssemblyInfo(propertyInfo); } foreach (PropertyInfo propertyInfo in type.GetDeclaredProperties().Where(x => x.GetGetMethod() != null && x.GetGetMethod().GetParameters().Count() > 0)) { DotNetIndexer indexer = Properties.OfType <DotNetIndexer>().Cast <DotNetIndexer>().FirstOrDefault(i => i.MatchesSignature(propertyInfo.GetGetMethod())); if (indexer == null) { continue; } indexer.AddAssemblyInfo(propertyInfo); } foreach (MethodInfo methodInfo in type.GetDeclaredMethods()) { DotNetMethod method = Methods.FirstOrDefault(m => m.MatchesSignature(methodInfo)); if (method == null) { continue; } if (methodInfo.Attributes.IsPrivate() && method.Name.ExplicitInterface == null) { Methods.Remove(method); continue; } method.AddAssemblyInfo(methodInfo); } foreach (ConstructorInfo constructorInfo in type.GetDeclaredConstructors()) { DotNetMethodConstructor method = Methods.OfType <DotNetMethodConstructor>().Cast <DotNetMethodConstructor>().FirstOrDefault(m => m.MatchesArguments(constructorInfo.GetParameters())); if (method == null) { continue; } method.AddAssemblyInfo(constructorInfo); } foreach (EventInfo eventInfo in type.GetDeclaredEvents()) { DotNetEvent e = Events.FirstOrDefault(m => m.Name.LocalName == eventInfo.Name); if (e == null) { continue; } e.AddAssemblyInfo(eventInfo); } foreach (Type nestedType in type.GetDeclaredNestedTypes()) { DotNetQualifiedName qualifiedName = DotNetQualifiedName.FromAssemblyInfo(nestedType); DotNetType dotNetNestedType = NestedTypes.FirstOrDefault(x => x.Owns(qualifiedName)); if (dotNetNestedType == null) { continue; } dotNetNestedType.AddAssemblyInfo(type, qualifiedName); } PushGenericTypes(); }