Created
June 4, 2011 04:07
-
-
Save AlexCuse/1007568 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ObjectFactory.Initialize(fun x -> x.AddRegistry (new SearchRegistry())) | |
let write<'T> item = | |
async { | |
ObjectFactory.GetAllInstances<Indexer<'T>>() | |
|> Seq.iter (fun idxr -> idxr.Index item) | |
} | |
let itemsToIndex<'T when 'T:null and 'T:not struct and 'T:equality> = | |
let p = QueueProvider<'T>.Create() | |
seq { | |
while true do | |
let obj = p.Dequeue() | |
if not (obj = null) then yield obj | |
} | |
try | |
Seq.concat [ | |
(itemsToIndex<Recipe> |> Seq.map write) | |
(itemsToIndex<Malt> |> Seq.map write) | |
(itemsToIndex<Hop> |> Seq.map write) | |
(itemsToIndex<Addition> |> Seq.map write) | |
(itemsToIndex<Yeast> |> Seq.map write) | |
] | |
|> Async.Parallel | |
|> Async.RunSynchronously | |
|> ignore | |
finally | |
SearchRegistry.DeRegister() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment