private ITypeSpecImmutable GetSpecificationFromCache(Type type) { var key = TypeKeyUtils.GetKeyForType(type); TypeUtils.GetType(type.FullName); // This should ensure type is cached return(cache.GetSpecification(key)); }
public virtual bool IsIgnored(Type type) { var returnType = TypeKeyUtils.FilterNullableAndProxies(type); return(IsTypeIgnored(returnType) || IsTypeUnsupportedByReflector(returnType) || FasterTypeUtils.IsGenericCollection(type) && type.GetGenericArguments().Any(IsIgnored)); }
public bool IsTypeRecognized(Type type) { var returnType = TypeKeyUtils.FilterNullableAndProxies(type); return(!IsTypeIgnored(returnType) && !IsTypeUnsupportedByReflector(returnType) && IsTypeWhiteListed(returnType) && (!FasterTypeUtils.IsGenericCollection(type) || type.GetGenericArguments().All(IsTypeRecognized))); }
public ITypeSpecImmutable GetSpecification(Type type, bool allowNull = false) { try { var spec = GetSpecificationFromCache(TypeKeyUtils.FilterNullableAndProxies(type)); if (spec == null && !allowNull) { throw new NakedObjectSystemException(logger.LogAndReturn($"Failed to Load Specification for: {type?.FullName} error: unexpected null")); } return(spec); } catch (NakedObjectSystemException e) { logger.LogError($"Failed to Load Specification for: {(type == null ? "null" : type.FullName)} error: {e}"); throw; } catch (Exception e) { throw new NakedObjectSystemException(logger.LogAndReturn($"Failed to Load Specification for: {type?.FullName} error: {e}")); } }
private static int?GetValueTypeTypicalLength(Type type, IClassStrategy classStrategy) { var actualType = TypeKeyUtils.FilterNullableAndProxies(type); if (actualType is not null) { if (actualType.IsArray) { var elementType = actualType.GetElementType(); if (elementType == typeof(string)) { return(null); } // byte[] has special facet factory if (elementType is not null && elementType.IsValueType && elementType == typeof(byte)) { return(20); } return(null); } if (actualType.IsEnum) { return(11); } if (TypeMap.ContainsKey(actualType)) { return(TypeMap[actualType]); } } return(null); }
public bool Filters(MethodInfo method, IClassStrategy classStrategy) => TypeKeyUtils.IsSystemClass(method.DeclaringType);
public bool Filters(PropertyInfo property, IClassStrategy classStrategy) => TypeKeyUtils.IsSystemClass(property.DeclaringType);
public void Add(Type type, ITypeSpecBuilder spec) => cache.Cache(TypeKeyUtils.GetKeyForType(type), spec);