Type GetSystemType(IType entity) { Type existingType; if (_typeCache.TryGetValue(entity, out existingType)) return existingType; Type type = SystemTypeFrom(entity); if (type == null) throw new InvalidOperationException(string.Format("Could not find a Type for {0}.", entity)); _typeCache.Add(entity, type); return type; }