/// <summary>
 /// Overridden ProcessRecord method.
 /// </summary>
 protected override void ProcessRecord()
 {
     if (!string.IsNullOrWhiteSpace(TypeName))
     {
         NtType type_info = NtType.GetTypeByName(TypeName, false);
         if (type_info != null)
         {
             WriteObject(type_info);
         }
         else
         {
             throw new ArgumentException(String.Format("Invalid Type Name {0}", TypeName));
         }
     }
     else
     {
         WriteObject(NtType.GetTypes(), true);
     }
 }
 /// <summary>
 /// Overridden ProcessRecord method.
 /// </summary>
 protected override void ProcessRecord()
 {
     if (!string.IsNullOrWhiteSpace(TypeName))
     {
         NtType type_info = NtType.GetTypeByName(TypeName, false, !CurrentStatus);
         if (type_info != null)
         {
             WriteObject(type_info);
         }
         else
         {
             throw new ArgumentException($"Invalid Type Name {TypeName}");
         }
     }
     else
     {
         WriteObject(NtType.GetTypes(!CurrentStatus), true);
     }
 }
 /// <summary>
 /// Overridden ProcessRecord method.
 /// </summary>
 protected override void ProcessRecord()
 {
     if (TypeName != null && TypeName.Length > 0)
     {
         foreach (var name in TypeName)
         {
             NtType type_info = NtType.GetTypeByName(name, false, !CurrentStatus);
             if (type_info != null)
             {
                 WriteObject(type_info);
             }
             else
             {
                 WriteError(new ErrorRecord(new ArgumentException($"Invalid Type Name {name}"),
                                            "Invalid.Type", ErrorCategory.InvalidArgument, name));
             }
         }
     }
     else
     {
         WriteObject(NtType.GetTypes(!CurrentStatus), true);
     }
 }
 public IEnumerable <CompletionResult> CompleteArgument(string commandName, string parameterName,
                                                        string wordToComplete, CommandAst commandAst, IDictionary fakeBoundParameters)
 {
     return(NtType.GetTypes().Where(t => t.Name.StartsWith(wordToComplete))
            .Select(t => new CompletionResult(MapString(t.Name))));
 }
        static void Main(string[] args)
        {
            bool require_security = false;
            bool verbose          = false;
            bool show_help        = false;
            bool name_only        = false;
            bool sorted           = false;

            OptionSet opts = new OptionSet()
            {
                { "v", "Display verbose information about type", v => verbose = v != null },
                { "s", "Show types which do not require security", v => require_security = v != null },
                { "n", "Display name only", v => name_only = v != null },
                { "t", "Display sorted by type name", v => sorted = v != null },
                { "h|help", "show this message and exit", v => show_help = v != null },
            };

            HashSet <string> typeFilter = new HashSet <string>(opts.Parse(args), StringComparer.OrdinalIgnoreCase);

            if (show_help)
            {
                ShowHelp(opts);
            }
            else
            {
                try
                {
                    IEnumerable <NtType> types = NtType.GetTypes();

                    if (typeFilter.Count > 0)
                    {
                        types = types.Where(t => typeFilter.Contains(t.Name));
                    }

                    if (require_security)
                    {
                        types = types.Where(t => !t.SecurityRequired);
                    }

                    if (sorted)
                    {
                        types = types.OrderBy(t => t.Name);
                    }

                    if (name_only)
                    {
                        foreach (NtType type in types)
                        {
                            Console.WriteLine("{0}", type.Name);
                        }
                    }
                    else
                    {
                        if (!verbose)
                        {
                            DumpGenericTypeInfo(types);
                        }
                        else
                        {
                            DumpVerboseTypeInfo(types);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine(ex.Message);
                }
            }
        }