Given typewith various properties, how to extract the type of a property when a property array, listor seq?
Code example below
type Car = { name: string }
type CarStore =
{ name: string
cars: Car[]
names: string list
others: string seq
others2: ResizeArray<string> }
let peek x =
Dump x
x
let extractTypeInfo name (typ:Type) =
let isEnumerable = true
let underlyingType = typ
isEnumerable, underlyingType
typeof<CarStore>.GetProperties()
|> peek
|> Seq.map (fun p -> extractTypeInfo p.Name p.PropertyType)
|> Dump
The implementation of the above gives the following properties:
- name:
String - cars:
IStructuralEquatable[] - names:
FSharpList<String> - others:
IEnumerable<String> - others2:
List<String>
How to update extractTypeInfoto get the following information
- name:
String - cars:
Car - names:
String - others:
String - others2:
String
source
share