public delegate bool Filter(T dinfo); protected void TestExtensionWithLambda()
{
Console.WriteLine("Enter the Min number of nested files:");
var noS = Console.ReadLine();
//IEnumerable directories = GetDirectories().OrderBy(d=>d.GetDirectories().Length);
IEnumerable<DirectoryInfo> directories = from d in GetDirectories()
orderby d.GetFiles().Length descending
select d;
var result = directories.Filter(d => d.GetFiles().Length >= int.Parse(noS));
Console.WriteLine("Original Collection={0}", directories.Count());
foreach (var dInfo in result)
{
Console.WriteLine("Name={0}, Dirctory Count={1}", dInfo.Name, dInfo.GetFiles().Length);
}
}
protected static IEnumerable<DirectoryInfo> GetDirectories()
{
var dInfo = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
var dInfos = dInfo.GetDirectories("*", SearchOption.AllDirectories);
var list = from d in dInfos
select d;
return list;
}