public IImmutableDictionary <string, ITypeSpecBuilder> IntrospectType(Type typeToIntrospect, ITypeSpecImmutable spec, IImmutableDictionary <string, ITypeSpecBuilder> metamodel) { if (!TypeUtils.IsPublic(typeToIntrospect)) { throw new ReflectionException(Log.LogAndReturn(string.Format(Resources.NakedObjects.DomainClassReflectionError, typeToIntrospect))); } IntrospectedType = typeToIntrospect; SpecificationType = GetSpecificationType(typeToIntrospect); properties = typeToIntrospect.GetProperties(); methods = GetNonPropertyMethods(); identifier = new IdentifierImpl(FullName); // Process facets at object level // this will also remove some methods, such as the superclass methods. var methodRemover = new IntrospectorMethodRemover(methods); metamodel = FacetFactorySet.Process(reflector, IntrospectedType, methodRemover, spec, metamodel); if (SuperclassType != null && ClassStrategy.IsTypeToBeIntrospected(SuperclassType)) { var result = reflector.LoadSpecification(SuperclassType, metamodel); metamodel = result.Item2; Superclass = result.Item1; } AddAsSubclass(spec); var interfaces = new List <ITypeSpecBuilder>(); foreach (Type interfaceType in InterfacesTypes) { if (interfaceType != null && ClassStrategy.IsTypeToBeIntrospected(interfaceType)) { var result = reflector.LoadSpecification(interfaceType, metamodel); metamodel = result.Item2; var interfaceSpec = result.Item1; interfaceSpec.AddSubclass(spec); interfaces.Add(interfaceSpec); } } Interfaces = interfaces.ToArray(); metamodel = IntrospectPropertiesAndCollections(spec, metamodel); metamodel = IntrospectActions(spec, metamodel); return(metamodel); }
public void IntrospectType(Type typeToIntrospect, ITypeSpecImmutable spec) { Log.InfoFormat("introspecting {0}: class-level details", typeToIntrospect.FullName); if (!TypeUtils.IsPublic(typeToIntrospect)) { throw new ReflectionException(string.Format(Resources.NakedObjects.DomainClassReflectionError, typeToIntrospect)); } IntrospectedType = typeToIntrospect; properties = typeToIntrospect.GetProperties(); methods = GetNonPropertyMethods(); // Process facets at object level // this will also remove some methods, such as the superclass methods. var methodRemover = new IntrospectorMethodRemover(methods); FacetFactorySet.Process(reflector, IntrospectedType, methodRemover, spec); if (SuperclassType != null && ClassStrategy.IsTypeToBeIntrospected(SuperclassType)) { Superclass = reflector.LoadSpecification(SuperclassType); } AddAsSubclass(spec); var interfaces = new List <ITypeSpecBuilder>(); foreach (Type interfaceType in InterfacesTypes) { if (interfaceType != null && ClassStrategy.IsTypeToBeIntrospected(interfaceType)) { var interfaceSpec = reflector.LoadSpecification(interfaceType); interfaceSpec.AddSubclass(spec); interfaces.Add(interfaceSpec); } } Interfaces = interfaces.ToArray(); IntrospectPropertiesAndCollections(spec); IntrospectActions(spec); }