Skip to content

Instantly share code, notes, and snippets.

@takeshik
Created June 6, 2011 20:13
Show Gist options
  • Select an option

  • Save takeshik/1010998 to your computer and use it in GitHub Desktop.

Select an option

Save takeshik/1010998 to your computer and use it in GitHub Desktop.
EnumerableEx.Generate(
EnumerableEx.Return((Expression) expr),
_ => _.Any(),
_ => _.SelectMany(e =>
EnumerableEx.Generate(e.GetType(), t => t.BaseType != null, t => t.BaseType, t => t)
.SelectMany(t => t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance))
.Where(t => t.FieldType.IsAssignableFrom(typeof(Expression)))
.Select(f => (Expression) f.GetValue(e))
),
_ => _
).SelectMany(_ => _);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment