You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.1 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Management.Automation;
  6. using System.Text;
  7. using ICSharpCode.Decompiler.CSharp;
  8. using ICSharpCode.Decompiler.TypeSystem;
  9. namespace ICSharpCode.Decompiler.PowerShell
  10. {
  11. [Cmdlet(VerbsCommon.Get, "DecompiledTypes")]
  12. [OutputType(typeof(ITypeDefinition[]))]
  13. public class GetDecompiledTypesCmdlet : PSCmdlet
  14. {
  15. [Parameter(Position = 0, Mandatory = true)]
  16. public CSharpDecompiler Decompiler { get; set; }
  17. [Parameter(Mandatory = true)]
  18. public string[] Types { get; set; }
  19. protected override void ProcessRecord()
  20. {
  21. HashSet<TypeKind> kinds = TypesParser.ParseSelection(Types);
  22. try
  23. {
  24. List<ITypeDefinition> output = new List<ITypeDefinition>();
  25. foreach (var type in Decompiler.TypeSystem.MainModule.TypeDefinitions)
  26. {
  27. if (!kinds.Contains(type.Kind))
  28. continue;
  29. output.Add(type);
  30. }
  31. WriteObject(output.ToArray());
  32. }
  33. catch (Exception e)
  34. {
  35. WriteVerbose(e.ToString());
  36. WriteError(new ErrorRecord(e, ErrorIds.DecompilationFailed, ErrorCategory.OperationStopped, null));
  37. }
  38. }
  39. }
  40. }