-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathGetDebuggerModuleCommand.cs
More file actions
40 lines (36 loc) · 1005 Bytes
/
GetDebuggerModuleCommand.cs
File metadata and controls
40 lines (36 loc) · 1005 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System.Linq;
using System.Management.Automation;
namespace PSExt.Commands
{
[Cmdlet(VerbsCommon.Get, "DbgModule")]
[OutputType(typeof (ModuleData))]
[Alias("lm")]
public class GetDebuggerModuleCommand : DbgBaseCmdlet
{
[Parameter(Position = 1)]
[SupportsWildcards]
public string[] Include { get; set; }
[Parameter(Position = 2)]
[SupportsWildcards]
public string[] Exclude { get; set; }
protected override void EndProcessing()
{
var includePattern = Include?.Select(i => new WildcardPattern(i, WildcardOptions.IgnoreCase)).ToArray();
var excludePattern = Exclude?.Select(i => new WildcardPattern(i, WildcardOptions.IgnoreCase)).ToArray();
foreach (var mod in Debugger.GetModules())
{
if (excludePattern != null)
{
if (excludePattern.Any(ex => ex.IsMatch(mod.ModuleName)))
{
continue;
}
}
if (includePattern == null || includePattern.Any(inc => inc.IsMatch(mod.ModuleName)))
{
WriteObject(mod);
}
}
}
}
}