PageRenderTime 18ms CodeModel.GetById 14ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/rocks/Mono.Cecil.Rocks/ModuleDefinitionRocks.cs

http://github.com/jbevain/cecil
C# | 32 lines | 17 code | 5 blank | 10 comment | 2 complexity | 8170caf31a0d575385b9a26630003ba7 MD5 | raw file
 1//
 2// Author:
 3//   Jb Evain (jbevain@gmail.com)
 4//
 5// Copyright (c) 2008 - 2015 Jb Evain
 6// Copyright (c) 2008 - 2011 Novell, Inc.
 7//
 8// Licensed under the MIT/X11 license.
 9//
10
11using System;
12using System.Collections.Generic;
13using System.Linq;
14
15namespace Mono.Cecil.Rocks {
16
17#if INSIDE_ROCKS
18	public
19#endif
20	static class ModuleDefinitionRocks {
21
22		public static IEnumerable<TypeDefinition> GetAllTypes (this ModuleDefinition self)
23		{
24			if (self == null)
25				throw new ArgumentNullException ("self");
26
27			// it was fun to write, but we need a somewhat less convoluted implementation
28			return self.Types.SelectMany (
29				Functional.Y<TypeDefinition, IEnumerable<TypeDefinition>> (f => type => type.NestedTypes.SelectMany (f).Prepend (type)));
30		}
31	}
32}