RicoSuter / Namotion.Reflection

.NET library with advanced reflection APIs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add tuple item name reflection to contextual types

RicoSuter opened this issue · comments

I have a technique to read a tuple type information in my project. Here's a link.

It may be not so relevant to the Namotion.Reflection library. Here's an algorithm description I used:

  1. For a given tuple understand there's named elements.
  2. Extract metadata of the tuple element names (all names go in a simple list of strings the similar way as for the NRT annotations).
  3. Make a pointer to the first name in the extracted names. This pointer will be needed to read nested tuples.
  4. Read the tuple type information
    3.1. Get element types (needs to be flatten in case of a tuple of 8 or more elements)
    3.2. Based on element count (flatten) extract a chunk of the element names associated with the current tuple.
    3.3. Zip element types and names to get a type and name information about each tuple element.
    3.4. Shift the name pointer to the next tuple element names chunk (+current tuple element count).
  5. Recursively read the current tuple element types. If there's a nested tuple found move to the step 3.