public EnumTypeData(ITypeWrapper typeToAnalyze) { AttributeData = new List<IAttributeData>(); MethodData = new List<IMethodData>(); FieldData = new List<IFieldData>(); if (!typeToAnalyze.IsEnum) { throw new NtegrityException("Type: " + typeToAnalyze.AssemblyQualifiedName + " is not an Enum."); } Name = typeToAnalyze.FullName; Type = TypeEnum.Enum; var foundAccessLevel = false; if (typeToAnalyze.IsNestedPrivate) { AccessLevel = AccessLevelEnum.Private; foundAccessLevel = true; } if (!typeToAnalyze.IsVisible && typeToAnalyze.IsNotPublic || typeToAnalyze.IsNestedAssembly) { AccessLevel = AccessLevelEnum.Internal; foundAccessLevel = true; } if (typeToAnalyze.IsPublic || typeToAnalyze.IsNestedPublic) { AccessLevel = AccessLevelEnum.Public; foundAccessLevel = true; } if (typeToAnalyze.IsNestedFamily) { AccessLevel = AccessLevelEnum.Protected; foundAccessLevel = true; } if (!foundAccessLevel) { throw new NtegrityException("Unable to determine access level for type: " + typeToAnalyze.AssemblyQualifiedName); } CollectAttributeData(typeToAnalyze); AttributeData = AttributeData.OrderBy(x => x.Name).ToList(); CollectMethodData(typeToAnalyze); MethodData = MethodData.OrderBy(x => x.MethodSignature).ToList(); CollectFieldData(typeToAnalyze); FieldData = FieldData.OrderBy(x => x.FieldSignature).ToList(); ImplementsInterfaces = typeToAnalyze.GetInterfaces().Select(x => x.FullName).ToList(); }
public InterfaceTypeData(ITypeWrapper typeToAnalyze) { Name = typeToAnalyze.FullName; if (!typeToAnalyze.IsInterface) { throw new NtegrityException("non-interface type passed to InterfaceTypeData's constructor!"); } Type = TypeEnum.Interface; var foundAccessLevel = false; if (typeToAnalyze.IsNestedPrivate) { AccessLevel = AccessLevelEnum.Private; foundAccessLevel = true; } if (!typeToAnalyze.IsVisible && typeToAnalyze.IsNotPublic || typeToAnalyze.IsNestedAssembly) { AccessLevel = AccessLevelEnum.Internal; foundAccessLevel = true; } if (typeToAnalyze.IsPublic || typeToAnalyze.IsNestedPublic) { AccessLevel = AccessLevelEnum.Public; foundAccessLevel = true; } if (typeToAnalyze.IsNestedFamily) { AccessLevel = AccessLevelEnum.Protected; foundAccessLevel = true; } if (!foundAccessLevel) { throw new NtegrityException("Unable to determine access level for type: " + typeToAnalyze.AssemblyQualifiedName); } IsSealed = typeToAnalyze.IsSealed; IsAbstract = typeToAnalyze.IsAbstract; // static types are both sealed and abstract. They can neither be inherited from nor instantiated. IsStatic = IsSealed && IsAbstract; CollectAttributeData(typeToAnalyze); AttributeData = AttributeData.OrderBy(x => x.Name).ToList(); CollectConstructorData(typeToAnalyze); ConstructorData = ConstructorData.OrderBy(x => x.ConstructorSignature).ToList(); CollectMethodData(typeToAnalyze); MethodData = MethodData.OrderBy(x => x.MethodSignature).ToList(); CollectPropertyData(typeToAnalyze); PropertyData = PropertyData.OrderBy(x => x.PropertySignature).ToList(); CollectFieldData(typeToAnalyze); FieldData = FieldData.OrderBy(x => x.FieldSignature).ToList(); if (typeToAnalyze.BaseType != null && typeToAnalyze.BaseType.FullName != "System.Object" && typeToAnalyze.BaseType.FullName != "System.ValueType" && typeToAnalyze.BaseType.FullName != "System.Enum") { InheritsFrom = typeToAnalyze.BaseType.FullName; } ImplementsInterfaces = typeToAnalyze.GetInterfaces().Select(x => x.FullName).ToList(); }