Prototype lazy type graphs
Closed this issue · 1 comments
warriordog commented
This is an idea for an improvement + optimization for the type graph system. It introduces some complexity, but has some key benefits:
- This finally clears the way to #134.
- Performance improvement - we only convert entities that are actually used.
- Removes dependency on ASTypeInfoCache
There may also be an opportunity to reduce the use of pivots by developing an EntityFactory
or similar. That could be injected into TypeGraphReader
and used to construct the appropriate entity types in a more-efficient way.
Proposed design (WIP):
- Create new internal class
TypeGraphReader
:- Contains all the entity conversion logic from
TypeMapConverter
. - Works on
JsonElement
directly.
- Contains all the entity conversion logic from
- Create new internal class
JsonTypeMap
(name TBD):- Requires a
JsonElement
and theTypeGraphReader
. - Expose functions to read entities, types, context, and metdata.
- Requires a
- Update
TypeMap
:- Add internal constructor that accepts and wraps a
JsonTypeMap
. - "get" methods Fall back on
JsonTypeMap
if available.
- Add internal constructor that accepts and wraps a
- Update
TypeMapConverter
:- Construct a singleton
TypeGraphReader
. - Remove entity conversion and construct a
JsonTypeMap
instead.
- Construct a singleton
warriordog commented
Updated design to account for ASP.NET Core - Dependency Injection is not available in middleware. TypeMapConverter
must have a no-args constructor.