-
Notifications
You must be signed in to change notification settings - Fork 15
/
TypeProviderAssembly.fs
40 lines (32 loc) · 1.38 KB
/
TypeProviderAssembly.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
namespace FSharp.Data.Npgsql
open System.Reflection
open Microsoft.FSharp.Core.CompilerServices
open ProviderImplementation.ProvidedTypes
open System.Collections.Concurrent
open FSharp.Data.Npgsql.DesignTime
open System.IO
[<TypeProvider>]
type NpgsqlProviders(config) as this =
inherit TypeProviderForNamespaces(
config,
assemblyReplacementMap = [("FSharp.Data.Npgsql.DesignTime", Path.GetFileNameWithoutExtension(config.RuntimeAssembly))]
)
let cache = ConcurrentDictionary()
do
this.Disposing.Add <| fun _ ->
try
cache.Clear()
NpgsqlConnectionProvider.methodsCache.Clear()
with _ -> ()
do
let assembly = Assembly.GetExecutingAssembly()
let assemblyName = assembly.GetName().Name
let nameSpace = this.GetType().Namespace
assert (typeof<``ISqlCommand Implementation``>.Assembly.GetName().Name = assemblyName)
assembly.Location |> Path.GetDirectoryName |> this.RegisterProbingFolder
this.AddNamespace(
nameSpace, [
NpgsqlCommandProvider.getProviderType(assembly, nameSpace, config.IsHostedExecution, config.ResolutionFolder, cache)
NpgsqlConnectionProvider.getProviderType(assembly, nameSpace, config.IsHostedExecution, config.ResolutionFolder, cache)
]
)