Skip to content

Class TypeUtils

Namespace: Momentum.Extensions.EventMarkdownGenerator.Services
Assembly: Momentum.Extensions.EventMarkdownGenerator.dll

Shared utility methods for type checking and name formatting. Consolidates type-related logic from multiple service classes.

csharp
public static class TypeUtils

Inheritance

objectTypeUtils

Inherited Members

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Methods

CollectComplexTypesFromProperties(IEnumerable<EventPropertyMetadata>)

Collects all complex types from a collection of event properties.

csharp
public static HashSet<Type> CollectComplexTypesFromProperties(IEnumerable<EventPropertyMetadata> properties)

Parameters

properties IEnumerable<EventPropertyMetadata>

Returns

HashSet<Type>

CollectNestedComplexTypes(Type, HashSet<Type>)

Collects all nested complex types from a parent type recursively.

csharp
public static void CollectNestedComplexTypes(Type parentType, HashSet<Type> schemaTypes)

Parameters

parentType Type

schemaTypes HashSet<Type>

GetElementType(Type)

Gets the element type from a collection type (arrays or generic collections).

csharp
public static Type? GetElementType(Type type)

Parameters

type Type

Returns

Type?

GetElementTypeName(Type)

Gets the element type name from a collection type.

csharp
public static string? GetElementTypeName(Type type)

Parameters

type Type

Returns

string?

GetFriendlyTypeName(Type)

Gets a friendly display name for a type (e.g., "string" instead of "String"). Handles nullable types and generics appropriately.

csharp
public static string GetFriendlyTypeName(Type type)

Parameters

type Type

Returns

string

IsCollectionType(Type)

Determines if a type is a collection type (arrays, lists, etc.).

csharp
public static bool IsCollectionType(Type type)

Parameters

type Type

Returns

bool

IsComplexType(Type)

Determines if a type is complex (not a simple type, enum, or common framework type). Uses cycle detection to handle recursive type references.

csharp
public static bool IsComplexType(Type type)

Parameters

type Type

Returns

bool

IsPrimitiveType(Type)

Determines if a type is a simple value type (primitives, enums, common framework types).

csharp
public static bool IsPrimitiveType(Type type)

Parameters

type Type

Returns

bool