ReflectionServiceGetClassForClassInstanceByAttribute(Type, Type, Object, Type) Method |
Tries to get a class instance for a given attribute type. All loaded assemblies are searched for classes that attributeType applies to,
then for all found classes the instantiation of a class is tried, until a instance is created successfully. Here, the attributeType has
to implement
IClassForClassAttribute, and creationArg[0] has to match the type in
TargetType Namespace: Altaxo.Main.ServicesAssembly: AltaxoBase (in AltaxoBase.dll) Version: 4.8.3179.0 (4.8.3179.0)
Syntax public static Object? GetClassForClassInstanceByAttribute(
Type attributeType,
Type[] expectedTypes,
Object[] creationArgs,
Type? overrideArgs0Type
)
Parameters
- attributeType Type
- The type of attribute the class(es) to instantiate must be assigned to.
- expectedTypes Type
- The expected type of return value.
- creationArgs Object
- The creation arguments used to instantiate a class.
- overrideArgs0Type Type
- Usually null. If you provide a type here, it has to be a base type of the typeof(creationArgs[0]). By this you
can "downgrade" creationArgs[0], so that only attributes for the base type are looked for.
Return Value
ObjectThe instance of the first class for which the instantiation was successfull and results in the expectedType. Otherwise null.
Remarks The instantiation is tried first with the full argument list. If that fails, the last element of the argument list is chopped and the instantiation is tried again.
This process is repeated until the instantiation was successfull or the argument list is empty (empty constructor is tried at last).
See Also