public static bool IsIEnumerable(this Type type) { Type enumerableType; ienumerableCache.GetOrInsert(type, out enumerableType, ienumerableInsertion); return(enumerableType != null); }
public static TypeInfo GetTypeInfoFromCache(this Type type) { TypeInfo typeInfo; typeInfoCache.GetOrInsert(type, out typeInfo, typeInfoInsertion); return(typeInfo); }
public static Type GetElementType(Type type) { Type elementType; elementTypeCache.GetOrInsert(type, out elementType, elementTypeInsertion); return(elementType); }
public static object DefaultValue(this Type type) { object value; defaultValueCache.GetOrInsert(type, out value, defaultValueInsertion); return(value); }
public static bool IsDisposable(this Type type) { bool result; isIDisposableCache.GetOrInsert(type, out result, isIDisposableInsertion); return(result); }
public object GetService(Type serviceType) { if (serviceType == null) { return(null); } if (IServiceProviderType.Equals(serviceType)) { return(this); } ServiceDescriptor serviceDescriptor = serviceCollection.GetDescriptor(serviceType); string typeName = serviceType.FullName; switch (serviceDescriptor.Lifetime) { case ServiceLifetime.Singleton: case ServiceLifetime.Scoped: instances.GetOrInsert(serviceType, out object instance, type => serviceDescriptor.CreateInstance(this)); return(instance); case ServiceLifetime.Transient: return(serviceDescriptor.CreateInstance(this)); default: throw new NotImplementedException(); } }
public static ConstructorInfo[] GetConstructorsFromCache(this Type type) { ConstructorInfo[] constructors; constructorCache.GetOrInsert(type, out constructors, constructorInsertion); return(constructors); }