public ITypeDescription DescribeType(Type type) { var memberTypeDescription = (ITypeDescription)null; using (var readLock = TypeDescriptionCacheLock.AcquireReadLock()) { if (TypeDescriptionCache.TryGetValue(type.AssemblyQualifiedName, out memberTypeDescription)) return memberTypeDescription; } using (var writeLock = TypeDescriptionCacheLock.AcquireWriteLock()) { if (TypeDescriptionCache.TryGetValue(type.AssemblyQualifiedName, out memberTypeDescription)) return memberTypeDescription; if (type.ImplementsInterface(typeof(IEnumerable))) { memberTypeDescription = new ReflectionBasedEnumerableTypeDescription(); } else { memberTypeDescription = new ReflectionBasedTypeDescription(); } // memberTypeDescription is now a prototype only (not populated) // add it to Type Description Cache, so if it's self refrencing it can be resolved // Describe it in a separate step while still holding write lock TypeDescriptionCache.Add(type.AssemblyQualifiedName, memberTypeDescription); memberTypeDescription = DescribeTypeInternal(type, memberTypeDescription as ReflectionBasedTypeDescription); } return memberTypeDescription; }
public ILBasedEnumerableTypeDescription(ReflectionBasedEnumerableTypeDescription source) : base (source) { this.EnumerableSource = source; }