public (ITypeSpecBuilder, IImmutableDictionary <string, ITypeSpecBuilder>) LoadSpecification(Type type, IImmutableDictionary <string, ITypeSpecBuilder> metamodel) { if (type == null) { throw new NakedObjectSystemException("cannot load specification for null"); } var actualType = ClassStrategy.GetType(type) ?? type; var typeKey = ClassStrategy.GetKeyForType(actualType); return(!metamodel.ContainsKey(typeKey) ? LoadPlaceholder(actualType, metamodel) : (metamodel[typeKey], metamodel)); }
public Tuple <ITypeSpecBuilder, ImmutableDictionary <string, ITypeSpecBuilder> > LoadSpecification(Type type, ImmutableDictionary <string, ITypeSpecBuilder> metamodel) { Assert.AssertNotNull(type); var actualType = ClassStrategy.GetType(type); var typeKey = ClassStrategy.GetKeyForType(actualType); if (!metamodel.ContainsKey(typeKey)) { return(LoadPlaceholder(actualType, metamodel)); } return(new Tuple <ITypeSpecBuilder, ImmutableDictionary <string, ITypeSpecBuilder> >(metamodel[typeKey], metamodel)); }
private Type GetSpecificationType(Type type) { var actualType = ClassStrategy.GetType(type); if (IsGenericEnumerableOrSet(type)) { return(type.GetGenericTypeDefinition()); } if (type.IsArray && !(type.GetElementType().IsValueType || type.GetElementType() == typeof(string))) { return(typeof(System.Array)); } return(actualType); }
private ITypeSpecBuilder LoadSpecificationAndCache(Type type) { var actualType = ClassStrategy.GetType(type); if (actualType == null) { throw new ReflectionException(logger.LogAndReturn($"Attempting to introspect a non-introspectable type {type.FullName} ")); } var specification = CreateSpecification(actualType); if (specification == null) { throw new ReflectionException(logger.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, loggerFactory.CreateLogger <Introspector>())); return(specification); }
private ImmutableDictionary <string, ITypeSpecBuilder> GetPlaceholders(Type[] types) { return(types.Select(t => ClassStrategy.GetType(t)).Where(t => t != null).Distinct(new DR(ClassStrategy)).ToDictionary(t => ClassStrategy.GetKeyForType(t), t => GetPlaceholder(t, null)).ToImmutableDictionary()); }
private Type GetSpecificationType(Type type) => FasterTypeUtils.IsGenericCollection(type) ? type.GetGenericTypeDefinition() : FasterTypeUtils.IsObjectArray(type) ? typeof(Array) : ClassStrategy.GetType(type);