private IObjectSpecBuilder LoadSpecificationAndCache(Type type)
        {
            Type actualType = classStrategy.GetType(type);

            if (actualType == null)
            {
                throw new ReflectionException("Attempting to introspect a non-introspectable type " + type.FullName + " ");
            }

            IObjectSpecBuilder specification = CreateSpecification(actualType);

            if (specification == null)
            {
                throw new ReflectionException("unrecognised type " + actualType.FullName);
            }

            // We need the specification available in cache even though not yet fully introspected
            metamodel.Add(actualType, specification);

            specification.Introspect(facetDecoratorSet, new Introspector(this, metamodel));

            //if (actualType.IsGenericType && actualType.IsConstructedGenericType) {
            //    // introspect any generic type parameters
            //    actualType.GetGenericArguments().ForEach(t => LoadSpecificationAndCache(t));
            //}

            return(specification);
        }
Example #2
0
        private IMetamodelBuilder InstallSpecificationsParallel(Type[] types, IMetamodelBuilder metamodel, IReflectorConfiguration config)
        {
            var mm = GetPlaceholders(types);

            mm = IntrospectPlaceholders(mm);
            mm.ForEach(i => metamodel.Add(i.Value.Type, i.Value));
            return(metamodel);
        }
Example #3
0
        public void Build()
        {
            IImmutableDictionary <string, ITypeSpecBuilder> specDictionary = new Dictionary <string, ITypeSpecBuilder>().ToImmutableDictionary();

            // todo make unordered

            specDictionary = reflectors.OrderBy(r => r.Order).Aggregate(specDictionary, (current, reflector) => reflector.Reflect(current));
            Validate(specDictionary);


            specDictionary.ForEach(i => initialMetamodel.Add(i.Value.Type, i.Value));

            integrator.Integrate();
        }
Example #4
0
        private IMetamodelBuilder InstallSpecifications(Type[] ooTypes, Type[] records, Type[] functions, IMetamodelBuilder metamodel)
        {
            // first oo
            var mm = GetPlaceholders(ooTypes);

            mm = IntrospectPlaceholders(mm, () => new Introspector(this, FacetFactorySet, loggerFactory.CreateLogger <Introspector>()));
            // then functional
            var allFunctionalTypes = records.Union(functions).ToArray();

            var mm2 = GetPlaceholders(allFunctionalTypes);

            if (mm2.Any())
            {
                mm = mm.AddRange(mm2);
                mm = IntrospectPlaceholders(mm, () => new FunctionalIntrospector(this, FunctionalFacetFactorySet, functions));
            }

            mm.ForEach(i => metamodel.Add(i.Value.Type, i.Value));
            return(metamodel);
        }
        private ITypeSpecBuilder LoadSpecificationAndCache(Type type)
        {
            Type actualType = classStrategy.GetType(type);

            if (actualType == null)
            {
                throw new ReflectionException(Log.LogAndReturn($"Attempting to introspect a non-introspectable type {type.FullName} "));
            }

            ITypeSpecBuilder specification = CreateSpecification(actualType);

            if (specification == null)
            {
                throw new ReflectionException(Log.LogAndReturn($"unrecognised type {actualType.FullName}"));
            }

            // We need the specification available in cache even though not yet fully introspected
            metamodel.Add(actualType, specification);

            specification.Introspect(facetDecoratorSet, new Introspector(this));

            return(specification);
        }