Class ClassManager
A class used to associate string class names with custom types and a set of properties. It automatically adds properties specified by a base class to each of its subclasses.
Inherited Members
Namespace: Microsoft.XboxStudios.GameStateTracker.Generic
Assembly: GameStateTracker.Generic.dll
Syntax
public class ClassManager : IClassManager, IPropertyManager, ITypeChanger<IGameObject>, IClassDataProvider
Constructors
View SourceClassManager(StringComparison, IEnumerable<IClassDataProvider>?)
Initializes a new instance of the ClassManager class.
Declaration
public ClassManager(StringComparison comparisonType = StringComparison.OrdinalIgnoreCase, IEnumerable<IClassDataProvider>? classDataProviders = null)
Parameters
Type | Name | Description |
---|---|---|
StringComparison | comparisonType | The comparison type to use when comparing class names. |
IEnumerable<IClassDataProvider> | classDataProviders | One or more objects providing the names of game classes and properties for managed C# types. If null, the default providers DefaultClassDataProviders are used. |
Properties
View SourceClasses
Gets the collection of known class names.
Declaration
public IReadOnlyCollection<string> Classes { get; }
Property Value
Type | Description |
---|---|
IReadOnlyCollection<string> |
ComparisonType
Gets the comparison type to use when comparing class names.
Declaration
protected StringComparison ComparisonType { get; }
Property Value
Type | Description |
---|---|
StringComparison |
DefaultClassDataProviders
Gets the default objects providing the names of game classes and properties for managed C# types.
Declaration
public static IEnumerable<IClassDataProvider> DefaultClassDataProviders { get; }
Property Value
Type | Description |
---|---|
IEnumerable<IClassDataProvider> |
Methods
View SourceAddProperties(string, Type, params string[])
Adds properties to retrieve for the given class name or pattern.
Declaration
public void AddProperties(string classPattern, Type type, params string[] propertyNames)
Parameters
Type | Name | Description |
---|---|---|
string | classPattern | The game object class name, which may include wildcards with the '*' character. |
Type | type | The type to convert the game object to. |
string[] | propertyNames | The properties to retrieve. |
GetBaseClassNames(TypeInfo)
Gets the base class names for game objects associated with the type.
Declaration
public virtual IEnumerable<string> GetBaseClassNames(TypeInfo typeInfo)
Parameters
Type | Name | Description |
---|---|---|
TypeInfo | typeInfo | The type info. |
Returns
Type | Description |
---|---|
IEnumerable<string> | An enumerable of base class names. |
GetProperties(TypeInfo)
Gets the properties to retrieve for the given type.
Declaration
public IEnumerable<string> GetProperties(TypeInfo typeInfo)
Parameters
Type | Name | Description |
---|---|---|
TypeInfo | typeInfo | The game object type info. |
Returns
Type | Description |
---|---|
IEnumerable<string> | An enumeration of properties to retrieve. |
GetProperties(string?)
Gets the properties to retrieve for the given class name.
Declaration
public IEnumerable<string> GetProperties(string? className)
Parameters
Type | Name | Description |
---|---|---|
string | className | The game object class name. |
Returns
Type | Description |
---|---|
IEnumerable<string> | An enumeration of properties to retrieve. |
GetType(IGameObject)
Gets the target type for converting an object.
Declaration
protected virtual Type? GetType(IGameObject gameObject)
Parameters
Type | Name | Description |
---|---|---|
IGameObject | gameObject | The object. |
Returns
Type | Description |
---|---|
Type | The target type to convert to. |
GetType(string?)
Gets the target type for converting an object given its class name.
Declaration
protected virtual Type? GetType(string? className)
Parameters
Type | Name | Description |
---|---|---|
string | className | The class name. |
Returns
Type | Description |
---|---|
Type | The target type to convert to. |
HasClass(string?)
Determines if the class manager knows about the given class.
Declaration
public bool HasClass(string? className)
Parameters
Type | Name | Description |
---|---|---|
string | className | The class name. |
Returns
Type | Description |
---|---|
bool | Whether or not the class manager knows about the class. |
ImportSubclasses<T>(Assembly?)
Imports each subclass of the given type from the given assembly, and adds properties specified by GameProperty attributes.
Declaration
public void ImportSubclasses<T>(Assembly? assembly = null)
Parameters
Type | Name | Description |
---|---|---|
Assembly | assembly | The assembly to look for subclasses in. If null, the assembly the type is defined in. |
Type Parameters
Name | Description |
---|---|
T | The base class type. |
IsAssignableFrom(IGameObject, string)
Determines if the object has a base class with the given name.
Declaration
public bool IsAssignableFrom(IGameObject input, string className)
Parameters
Type | Name | Description |
---|---|---|
IGameObject | input | The game object. |
string | className | The class name. |
Returns
Type | Description |
---|---|
bool | True if the object is assignable from the given name. |
MatchesPattern(string, string?)
Determines if the class name matches the given pattern.
Declaration
protected virtual bool MatchesPattern(string pattern, string? className)
Parameters
Type | Name | Description |
---|---|---|
string | pattern | The pattern, using * as an optional wildcard at the end. |
string | className | The class name to compare against. |
Returns
Type | Description |
---|---|
bool | True if the class name matches the pattern. |
SetBaseClass(string, string)
Sets the base class name for a subclass.
Declaration
public bool SetBaseClass(string className, string subclass)
Parameters
Type | Name | Description |
---|---|---|
string | className | The base class name. |
string | subclass | The subclass name. |
Returns
Type | Description |
---|---|
bool | True if any subclasses were previously unknown. |
TryConvert(IGameObject, out IGameObject)
Attempts to convert the input object to a more specific type.
Declaration
public bool TryConvert(IGameObject input, out IGameObject output)
Parameters
Type | Name | Description |
---|---|---|
IGameObject | input | The object to convert. |
IGameObject | output | The output object. |
Returns
Type | Description |
---|---|
bool | True if the object was converted to more specific type. |