高级转换:

static IEnumerable<XElement> ExpandPaths (IEnumerable<string> paths)
{
var brokenUp = from path in paths
let split = path.Split (new char[] { '\\' }, 2)
orderby split[0]
select new
{
name = split[0],
remainder = split.ElementAtOrDefault (1)
}; IEnumerable<XElement> files = from b in brokenUp
where b.remainder == null
select new XElement ("file", b.name); IEnumerable<XElement> folders = from b in brokenUp
where b.remainder != null
group b.remainder by b.name into grp
select new XElement ("folder",
new XAttribute ("name", grp.Key),
ExpandPaths (grp)
); return files.Concat (folders);
} static void RunQuery()
{
XElement project = XElement.Load ("myProjectFile.csproj");
XName ns = project.Name.Namespace; IEnumerable<string> paths =
from compileItem in
project.Elements (ns + "ItemGroup").Elements (ns + "Compile")
let include = compileItem.Attribute ("Include")
where include != null
select include.Value; XElement query = new XElement ("Project", ExpandPaths (paths));
}

最新文章

  1. 一个免费的、跨平台的、开源音频编辑器Audacity
  2. 宠物收养所(bzoj1208)
  3. iOS 正则表达式判断邮箱、身份证..是否正确
  4. Android_gridVIew
  5. 总结: Struts2 + Spring 的线程安全问题
  6. 左右推拽显示对比图 - jQyery封装 - 附源文件
  7. IHttpModule接口事件执行 获取Session 找了很多国内的都不对,从国外转过来一个测试可用的
  8. Sublime Text 3 无法使用package control安装插件解决办法
  9. 8.2.5: Spring3.0新增的@DependsOn和@Lazy
  10. touch修改文件的修改时间和访问时间,ls --full-time显示文件详细,stat命令
  11. .net 在数据访问层中写一个DBhelper优化类
  12. Java--Dom解析XML文件
  13. Linux替换动态库导致正在运行的程序崩溃
  14. 关于python的展望
  15. 主流CTR预估模型的演化及对比
  16. wzoj install
  17. Isomorphism 同构
  18. 超详细的PS抠图方法
  19. 华中农业大学第五届程序设计大赛网络同步赛-K
  20. jzoj100044

热门文章

  1. Petshop学习第一天
  2. Android开发--ListPreferance 运行报错:android.preference.ListPreference.findIndexOfValue(ListPreference.java:169)
  3. sqlite 修改表名,合并数据库(文件)
  4. Java List 用法代码分析 非常详细
  5. A Tour of Go Methods
  6. 第一个android程序所遇到问题
  7. [置顶] Objective-C ,ios,iphone开发基础:protocol 协议(委托,代理)的声明
  8. android应用程序fps meter[帧数显示]的分析 —— 浅谈root的风险 (3)
  9. linux mail命令用法
  10. cocos2d-x CCSpriteBatchNode