Skip to content

Instantly share code, notes, and snippets.

@atifaziz
Created February 19, 2009 22:44
Show Gist options
  • Save atifaziz/67169 to your computer and use it in GitHub Desktop.
Save atifaziz/67169 to your computer and use it in GitHub Desktop.
LINQ query to generate table of MoreLINQ operators
(
from member
in XDocument.Load(@"C:\MoreLINQ\MoreLinq\bin\Debug\MoreLinq.xml")
.Root
.Elements("members")
.Elements("member")
let memberName = (string) member.Attribute("name")
let match = Regex.Match(memberName,
@"M:MoreLinq\.Pull\.(?<cat>[a-z]+)\.(?<op>[a-z]+)",
RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)
where match.Success
let opm = new
{
Name = match.Groups["op"].Value,
Category = match.Groups["cat"].Value,
Summary = Regex.Replace((string) member.Element("summary"), @"\s+", " ").Trim(),
Member = member,
}
orderby opm.Name
group opm by opm.Name into op
select string.Format(
"|| `{0}` || {1} || {2} ||",
op.Key, op.First().Category, op.First().Summary)
)
.Aggregate(
new StringBuilder(
"|| *Operator* || *Category* || *Summary* ||").AppendLine(),
(sb, row) => sb.AppendLine(row),
sb => sb.ToString())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment