using System;
using System.Collections.Generic;
using System.Linq;
namespace Chernobyl.Extensions
{
///
/// Extensions and utility methods for .
///
public static class FindExtensions
{
///
/// Returns the as its
/// equivalent.
///
/// The type of the key.
/// The type of the value to return to the callback.
/// The method to return as an .
/// as .
public static Action> AsAction(this Find find)
{
return new Action>(find);
}
///
/// Uses the to locate many values tied to
/// the and returning those values through the
/// in the order relative to their keys.
///
/// The method used to locate each item.
/// The keys that are tied to the values to locate.
/// The method to invoke once all of the values
/// are located.
public static void FindMany(this Find find,
IEnumerable keys,
Callback> callback)
{
var callbacks = callback.AsAction().AsMany(keys.Count());
find.AsAction()
.Bind(keys)
.AsOne()
.Invoke(callbacks);
}
}
}