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
// Given an XElement, remove all leaf nodes that do NOT contain a specific node. | |
// Also removes ancestor branches that do not result in the specific leaf node. | |
// Useful for pruning hierarchies, such as a disk directory structure that only shows | |
// directory paths that contain files | |
void Prune(XElement element) | |
{ | |
if (element.Elements().Any(e => e.Name.LocalName == "Page")) | |
{ | |
return; |
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
/* | |
* Replaces the default xmlns namesapce for the given XElement and its descendants | |
* with the specified target namespace | |
*/ | |
private static XElement RewriteNamespace(XElement element, XNamespace ns) | |
{ | |
RewriteChildNamespace(element, ns); | |
// cannot change ns of root element directly so must rebuild it |
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
async Task Main() | |
{ | |
var releases = new List<Release>(); | |
var page = 1; | |
while (await GetReleases(releases, page++)); | |
releases.Dump(); | |
} |
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
void Main() | |
{ | |
// remove all occurances of #region and #endregion from CS files under a root folder | |
var root = @"C:\Users\steve\Downloads\System_Windows_Forms_Calendar_003"; | |
var files = Directory.EnumerateFiles(root, "*.cs", SearchOption.AllDirectories); | |
if (files.Any()) | |
{ | |
var regex = new Regex(@"^\s*#(?:end)?region.*$"); |