Skip to content

Instantly share code, notes, and snippets.

@AlexCuse
Created June 4, 2011 04:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexCuse/1007568 to your computer and use it in GitHub Desktop.
Save AlexCuse/1007568 to your computer and use it in GitHub Desktop.
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