Beamable SDK
Public Types | Public Member Functions | List of all members
Beamable.Common.Reflection.ReflectionCache Class Reference

Used to initialize all reflection based systems with consistent validation and to ensure we are only doing the assembly sweeping once. We can also use this to setup up compile-time validation of our Attribute-based systems such as Content and Microservices. More...

Public Types

enum  ValidationResultType { Valid , Warning , Error , Discarded }
 Validation results used by AttributeValidationResult and, potentially, other validation structs.
 

Public Member Functions

 ReflectionCache ()
 Creates a new ReflectionCache instance.
 
void SetStorage (IBeamHintGlobalStorage hintGlobalStorage)
 
void ClearProviders ()
 Call to unregister all IReflectionTypeProvider from the ReflectionCache.
 
TReflectionUserSystem GetFirstSystemOfType< TReflectionUserSystem > ()
 Returns the first instance of the IReflectionSystem of type TReflectionUserSystem that was previously registered. Fails if no system of type TReflectionUserSystem is found. More...
 
void RegisterTypeProvider (IReflectionTypeProvider provider)
 Register a IReflectionTypeProvider with the cache. This must be called before Beamable's initialization or you must manage the initialization of this cache yourself. Type providers define which types should the ReflectionCache gather up and build maps around. See the properties of IReflectionTypeProvider for more info on how they are used.
 
bool TryRegisterTypeProvider (IReflectionTypeProvider provider)
 Register a IReflectionTypeProvider with the cache. This must be called before Beamable's initialization or you must manage the initialization of this cache yourself. Type providers define which types should the ReflectionCache gather up and build maps around. See the properties of IReflectionTypeProvider for more info on how they are used. More...
 
void RegisterReflectionSystem (IReflectionSystem system)
 Registers a IReflectionSystem with the Reflection Cache System. This must be called before Beamable's initialization or you must manage the initialization of this cache yourself. You can find Beamable's systems at: API.cs and EditorAPI.cs, for runtime dependencies and editor dependencies respectively.
 
bool TryRegisterReflectionSystem (IReflectionSystem system)
 Registers a IReflectionSystem with the Reflection Cache System. This must be called before Beamable's initialization or you must manage the initialization of this cache yourself. You can find Beamable's systems at: API.cs and EditorAPI.cs, for runtime dependencies and editor dependencies respectively. More...
 
void GenerateReflectionCache (IReadOnlyList< string > assembliesToSweep)
 This is a very slow function call. It triggers a full sweep of all assemblies in the project and regenerate _perBaseTypeCache and _perAttributeCache. Then, it invokes all callbacks of all IReflectionSystem registered via RegisterReflectionSystem. More...
 
void RebuildReflectionCache (IReadOnlyList< string > sortedAssembliesToSweep=null)
 This is a very slow function call. It triggers a full sweep of all assemblies in the project and regenerate _perBaseTypeCache and _perAttributeCache. Strive to call this once at initialization or editor reload.
 
void RebuildReflectionUserSystems (List< Type > userSystemTypesToRebuild=null)
 Goes through all _registeredCacheUserSystems and invokes their callbacks with the currently cached data.
 
bool TryFindBaseTypesOfInterest (Type type, IEnumerable< BaseTypeOfInterest > baseTypesToSearchIn, out BaseTypeOfInterest foundType)
 Checks type to see if it matches any of the BaseTypeOfInterest that were registered with the reflection cache. More...
 

Detailed Description

Used to initialize all reflection based systems with consistent validation and to ensure we are only doing the assembly sweeping once. We can also use this to setup up compile-time validation of our Attribute-based systems such as Content and Microservices.

Member Function Documentation

◆ GenerateReflectionCache()

void Beamable.Common.Reflection.ReflectionCache.GenerateReflectionCache ( IReadOnlyList< string >  assembliesToSweep)
inline

This is a very slow function call. It triggers a full sweep of all assemblies in the project and regenerate _perBaseTypeCache and _perAttributeCache. Then, it invokes all callbacks of all IReflectionSystem registered via RegisterReflectionSystem.

Parameters
assembliesToSweepA list of Assembly names for us to sweep in.

◆ GetFirstSystemOfType< TReflectionUserSystem >()

TReflectionUserSystem Beamable.Common.Reflection.ReflectionCache.GetFirstSystemOfType< TReflectionUserSystem > ( )
inline

Returns the first instance of the IReflectionSystem of type TReflectionUserSystem that was previously registered. Fails if no system of type TReflectionUserSystem is found.

Type Constraints
TReflectionUserSystem :IReflectionSystem 

◆ TryFindBaseTypesOfInterest()

bool Beamable.Common.Reflection.ReflectionCache.TryFindBaseTypesOfInterest ( Type  type,
IEnumerable< BaseTypeOfInterest baseTypesToSearchIn,
out BaseTypeOfInterest  foundType 
)
inline

Checks type to see if it matches any of the BaseTypeOfInterest that were registered with the reflection cache.

Parameters
typeThe current type being evaluated.
baseTypesToSearchInThe BaseTypeOfInterest to check type against.
foundTypeThe first BaseTypeOfInterest that matches.
Returns
true, if a type was found. false otherwise.

◆ TryRegisterReflectionSystem()

bool Beamable.Common.Reflection.ReflectionCache.TryRegisterReflectionSystem ( IReflectionSystem  system)
inline

Registers a IReflectionSystem with the Reflection Cache System. This must be called before Beamable's initialization or you must manage the initialization of this cache yourself. You can find Beamable's systems at: API.cs and EditorAPI.cs, for runtime dependencies and editor dependencies respectively.

Returns
True if the system was successfully added, or false if the system already existed in the cache.

◆ TryRegisterTypeProvider()

bool Beamable.Common.Reflection.ReflectionCache.TryRegisterTypeProvider ( IReflectionTypeProvider  provider)
inline

Register a IReflectionTypeProvider with the cache. This must be called before Beamable's initialization or you must manage the initialization of this cache yourself. Type providers define which types should the ReflectionCache gather up and build maps around. See the properties of IReflectionTypeProvider for more info on how they are used.

Returns
True if the type provider was successfully added, or false if the provider already existed in the cache.

The documentation for this class was generated from the following files: