Created
February 19, 2009 22:44
-
-
Save atifaziz/67169 to your computer and use it in GitHub Desktop.
LINQ query to generate table of MoreLINQ operators
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( | |
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