Class ContentTypeReaderManager
Defines a manager that constructs and keeps track of ContentTypeReader objects.
public sealed class ContentTypeReaderManager
- Inheritance
-
ContentTypeReaderManager
- Inherited Members
Methods
AddTypeCreator(string, Func<ContentTypeReader>)
Registers a function to create a ContentTypeReader instance used to read an object of the type specified. Call this method to register content readers that may fail loading when trimming or PublishAot are used.
public static void AddTypeCreator(string typeString, Func<ContentTypeReader> createFunction)
Parameters
typeString
stringA string containing the fully-qualified type name of the object type.
createFunction
Func<ContentTypeReader>The function responsible for creating an instance of the ContentTypeReader class.
Exceptions
- ArgumentNullException
If the
typeString
parameter is null or an empty string.
ClearTypeCreators()
Clears all content type creators that were registered with AddTypeCreator(string, Func<ContentTypeReader>)
public static void ClearTypeCreators()
GetTypeReader(Type)
Creates a new instance of the ContentReader class initialized for the specified type.
public ContentTypeReader GetTypeReader(Type targetType)
Parameters
targetType
TypeThe type the ContentReader will handle.
Returns
- ContentTypeReader
The ContentReader created by this method if a content reader of the specified type has been registered with this content manager; otherwise, null.
Exceptions
- ArgumentNullException
If the
targetType
parameter is null.
PrepareType(string)
Removes the Version, Culture, and PublicKeyToken from a fully-qualified type name string.
public static string PrepareType(string type)
Parameters
type
stringA string containing the fully-qualified type name to prepare.
Returns
- string
A new string with the Version, Culture and PublicKeyToken removed.
Remarks
Supports multiple generic types (e.g. Dictionary<TKey,TValue>) and nested generic types (e.g. List<List<int>>).