Skip to content

Commit

Permalink
[PrimitiveValueConverter] Add addConverters
Browse files Browse the repository at this point in the history
  • Loading branch information
hyazinthh committed Aug 21, 2024
1 parent bc72349 commit 7cbd213
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Aardvark.Base.FSharp/Utilities/PrimitiveValueConverter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1328,8 +1328,13 @@ module PrimitiveValueConverter =
prop.GetValue(null)

match tryGetConverterV valueType outType with
| ValueSome inner -> ValueSome <| compose toValue inner
| ValueNone -> ValueNone
| ValueSome inner ->
let conv = compose toValue inner
mapping.Add(inType, outType, conv)
ValueSome conv

| ValueNone ->
ValueNone

else
ValueNone
Expand All @@ -1343,6 +1348,13 @@ module PrimitiveValueConverter =
| ValueSome c -> c
| ValueNone -> raise <| InvalidConversionException($"Unknown conversion from {inType} to {outType}", inType, outType)

let addConverters (converters: #seq<obj>) =
lock mapping (fun _ ->
for c in converters do
let (i, o) = FSharpType.GetFunctionElements (c.GetType())
mapping.Add(i, o, c)
)

//open Aardvark.Base.IL
type private Invoker private() =
static let cache = System.Collections.Concurrent.ConcurrentDictionary<struct (Type * Type), obj -> obj -> obj>()
Expand Down

0 comments on commit 7cbd213

Please sign in to comment.