Interface IActivator
Provides methods that create class and exception instances from Slice type IDs.
public interface IActivator
Remarks
When decoding a Slice1-encoded buffer, a Slice decoder uses its activator to create a class or exception instance before decoding the instance's fields.
Methods
CreateInstance(string)
Creates an instance of a Slice class or Slice exception based on a type ID.
object? CreateInstance(string typeId)
Parameters
typeId
stringThe Slice type ID.
Returns
- object
A new instance of the class identified by
typeId
, or null if the implementation cannot find the corresponding C# class.
Remarks
This implementation of this method can also throw an exception if the class is found but the activation of an instance fails.
FromAssemblies(params Assembly[])
Gets or creates an activator for the Slice types defined in the specified assemblies and their referenced assemblies.
public static IActivator FromAssemblies(params Assembly[] assemblies)
Parameters
assemblies
Assembly[]The assemblies.
Returns
- IActivator
An activator that activates the Slice types defined in
assemblies
and their referenced assemblies. See FromAssembly(Assembly).
FromAssembly(Assembly)
Gets or creates an activator for the Slice types in the specified assembly and its referenced assemblies.
public static IActivator FromAssembly(Assembly assembly)
Parameters
assembly
AssemblyThe assembly.
Returns
- IActivator
An activator that activates the Slice types defined in
assembly
provided this assembly contains generated code (as determined by the presence of the SliceAttribute attribute). The Slice types defined in assemblies referenced byassembly
are included as well, recursively. If a referenced assembly contains no generated code, the assemblies it references are not examined.