VECTO Input Manager
Loading...
Searching...
No Matches
VectoInputManager.Core.TypeUtils Class Reference

Provides utility methods for working with types, including type discovery, component declarations, and type conversion operations. More...

Static Public Member Functions

static IReadOnlyList< Type > GetAllVehicleTypes ()
 Retrieves all types that implement VectoObjects.AbstractVehicleDeclarationType and includes VehicleDeclarationType.
static IReadOnlyList< Type > GetAllComponentDeclarationTypes ()
 Retrieves all concrete types that implement IComponentDeclaration.
static IEnumerable< Type > GetSelfAndDescendantTypes (Type type)
 Gets the specified type and all its concrete descendant types.
static IEnumerable<(IComponentDeclaration component, string path)> FindComponentDelarations (object obj, string? parentPath=null)
 Recursively finds all component declarations within an object hierarchy. Traverses through properties and collections to locate IComponentDeclaration instances.
static Type GetTypeByName (string typeName)
 Resolves a type name to a Type object from the VectoObjects assembly.
static Type GetTypeByNameStandardValues (string typeName)
 Resolves a standard values type name to a Type object from the VectoInputManagerCore assembly.
static ? Type GetTypeByNameOrNull (string typeName)
 Attempts to resolve a type name to a Type object, returning null if not found.
static VectoInputDeclaration_v2_2 CreateVectoInputDeclaration ()
 Creates a new VectoInputDeclaration_v2_2 instance with the schema version set.
static bool IsScaffoldingComponent (this IComponentDeclaration cd)
 Determines if a component is a scaffolding/placeholder component by checking if its Date property is set to default. Scaffolding components are typically empty templates that haven't been properly initialized.
static void EnsureIdSet (this IComponentDeclaration cd)
 Ensures that a component has an ID set in its Data property. If no ID exists, generates one using an auto-incrementing counter.
static void SetComponentInVectoInputDeclaration (this IVectoInputDeclaration vectoInputDeclaration, IComponentDeclaration component)
 Sets a component declaration into the appropriate property of a VectoInputDeclaration_v2_2. Handles special REESS component conversion (Battery/Capacitor) automatically.
static IComponentDeclaration UpgradeComponent (IComponentDeclaration component)
 Upgrades the component to a compatible type for VectoInputDeclaration_v2_2 if it's an older version v1_0.
static ? object DeepCopy (object obj)

Detailed Description

Provides utility methods for working with types, including type discovery, component declarations, and type conversion operations.

Member Function Documentation

◆ CreateVectoInputDeclaration()

VectoInputDeclaration_v2_2 VectoInputManager.Core.TypeUtils.CreateVectoInputDeclaration ( )
inlinestatic

Creates a new VectoInputDeclaration_v2_2 instance with the schema version set.

Returns
A new VectoInputDeclaration_v2_2 instance.

◆ EnsureIdSet()

void VectoInputManager.Core.TypeUtils.EnsureIdSet ( this IComponentDeclaration cd)
inlinestatic

Ensures that a component has an ID set in its Data property. If no ID exists, generates one using an auto-incrementing counter.

Parameters
cdThe component declaration to ensure has an ID.

◆ FindComponentDelarations()

IEnumerable<(IComponentDeclaration component, string path)> VectoInputManager.Core.TypeUtils.FindComponentDelarations ( object obj,
string? parentPath = null )
inlinestatic

Recursively finds all component declarations within an object hierarchy. Traverses through properties and collections to locate IComponentDeclaration instances.

Parameters
objThe root object to search within.
parentPathThe path prefix for tracking location (optional, for internal recursion).
Returns
An enumerable of tuples containing each found component and its path.

◆ GetAllComponentDeclarationTypes()

IReadOnlyList< Type > VectoInputManager.Core.TypeUtils.GetAllComponentDeclarationTypes ( )
inlinestatic

Retrieves all concrete types that implement IComponentDeclaration.

Returns
A list of all component declaration types.

◆ GetAllVehicleTypes()

IReadOnlyList< Type > VectoInputManager.Core.TypeUtils.GetAllVehicleTypes ( )
inlinestatic

Retrieves all types that implement VectoObjects.AbstractVehicleDeclarationType and includes VehicleDeclarationType.

Returns
A list of concrete vehicle declaration types.

◆ GetSelfAndDescendantTypes()

IEnumerable< Type > VectoInputManager.Core.TypeUtils.GetSelfAndDescendantTypes ( Type type)
inlinestatic

Gets the specified type and all its concrete descendant types.

Parameters
typeThe base type to find descendants for.
Returns
An enumerable of the type itself and all its non-abstract subclasses.
Exceptions
ArgumentNullExceptionThrown when type is null.

◆ GetTypeByName()

Type VectoInputManager.Core.TypeUtils.GetTypeByName ( string typeName)
inlinestatic

Resolves a type name to a Type object from the VectoObjects assembly.

Parameters
typeNameThe simple name of the type (without namespace).
Returns
The resolved Type.
Exceptions
TypeLoadExceptionThrown when the type cannot be found.

◆ GetTypeByNameOrNull()

? Type VectoInputManager.Core.TypeUtils.GetTypeByNameOrNull ( string typeName)
inlinestatic

Attempts to resolve a type name to a Type object, returning null if not found.

Parameters
typeNameThe simple name of the type (without namespace).
Returns
The resolved Type, or null if not found.

◆ GetTypeByNameStandardValues()

Type VectoInputManager.Core.TypeUtils.GetTypeByNameStandardValues ( string typeName)
inlinestatic

Resolves a standard values type name to a Type object from the VectoInputManagerCore assembly.

Parameters
typeNameThe simple name of the type (without namespace).
Returns
The resolved Type.
Exceptions
TypeLoadExceptionThrown when the type cannot be found.

◆ IsScaffoldingComponent()

bool VectoInputManager.Core.TypeUtils.IsScaffoldingComponent ( this IComponentDeclaration cd)
inlinestatic

Determines if a component is a scaffolding/placeholder component by checking if its Date property is set to default. Scaffolding components are typically empty templates that haven't been properly initialized.

Parameters
cdThe component declaration to check.
Returns
True if the component is a scaffolding component; otherwise, false.

◆ SetComponentInVectoInputDeclaration()

void VectoInputManager.Core.TypeUtils.SetComponentInVectoInputDeclaration ( this IVectoInputDeclaration vectoInputDeclaration,
IComponentDeclaration component )
inlinestatic

Sets a component declaration into the appropriate property of a VectoInputDeclaration_v2_2. Handles special REESS component conversion (Battery/Capacitor) automatically.

Parameters
vectoInputDeclarationThe target declaration to set the component into.
componentThe component to set.
Exceptions
ArgumentNullExceptionThrown when either parameter is null.
InvalidOperationExceptionThrown when no compatible property is found or multiple matches exist.

The documentation for this class was generated from the following file:
  • VectoInputManagerCore/TypeUtils.cs