-
Notifications
You must be signed in to change notification settings - Fork 1
/
ComponentsPerScope.fsx
42 lines (32 loc) · 1.37 KB
/
ComponentsPerScope.fsx
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
40
41
let targetFolder = @".\src\Castle.MonoRail\bin\Debug"
#I @"src\Castle.MonoRail\bin\Debug"
#r "System.ComponentModel.Composition.Codeplex.dll"
#r "Castle.MonoRail.dll"
open System.Reflection
open System.IO
open System.ComponentModel.Composition
open Castle.MonoRail.Framework
let asm = Assembly.LoadFrom(Path.Combine(targetFolder, "Castle.MonoRail.dll"))
let loaded_types =
try
asm.GetTypes()
with
| :? ReflectionTypeLoadException as ex -> ex.Types
let exports =
loaded_types
|> Seq.filter (fun t -> t <> null && t.GetCustomAttributes(typeof<ExportAttribute>, true).Length <> 0 )
let appcomponents =
exports
|> Seq.filter (fun t -> not (t.IsDefined(typeof<PartMetadataAttribute>, true)) ||
(t.GetCustomAttributes(typeof<PartMetadataAttribute>, true).[0] :?> PartMetadataAttribute).Value :?> ComponentScope = ComponentScope.Application )
let reqcomponents =
exports
|> Seq.filter (fun t -> (t.IsDefined(typeof<PartMetadataAttribute>, true)) &&
(t.GetCustomAttributes(typeof<PartMetadataAttribute>, true).[0] :?> PartMetadataAttribute).Value :?> ComponentScope = ComponentScope.Request )
printfn "App level components: "
for t in appcomponents do
printfn " %s" t.FullName
printfn "Req level components: "
for t in reqcomponents do
printfn " %s" t.FullName