Class TypeFactory
Special helper to create objects from a type.
[InternalApi_DoNotUse_MayChangeWithoutNotice]
public static class TypeFactory
- Inheritance
-
objectTypeFactory
Remarks
The type must have a parameterless constructor, otherwise it will throw an error.
Methods
CreateInstance(Type)
public static object CreateInstance(Type type)
Parameters
typeType
Returns
- object
CreateInstanceFunc(Type)
GetOrAdd ensures we only compile the expression once
public static Func<object> CreateInstanceFunc(Type type)
Parameters
typeType
Returns
- Func<object>
Exceptions
CreateInstance<T>()
The Generic Wrapper: Uses the central cache but returns the correct type.
public static T CreateInstance<T>() where T : class
Returns
- T
Type Parameters
T