Imports Microsoft.VisualBasic Imports System Imports System.Security Class App Public Shared Sub Main(args As String()) Dim ft As FindType = New FindType() Try SetOptions(args, ft) ft.Search() Catch e As SecurityException Console.WriteLine("This sample has failed to run due to a security limitation!" & Chr(10) & "Try running the sample from a local drive or using CasPol.exe to turn off security.") Catch PrintUsage() End Try End Sub Private Shared Sub PrintUsage() Console.WriteLine() Console.WriteLine("FindType [SystemOptions] [MatchOptions] [ShowOptions] [MiscOptions] Name") Console.WriteLine("") Console.WriteLine(" where SystemOptions") Console.WriteLine(" d:[Directory] - Additional directory to search") Console.WriteLine(" where MatchOptions") Console.WriteLine(" x - Name = Exact Type Name (including namespace)") Console.WriteLine(" n - Name = Namespace ") Console.WriteLine(" w - Match the name anywhere in the namespace") Console.WriteLine(" where ShowOptions") Console.WriteLine(" i - Show Interfaces") Console.WriteLine(" f - Show Fields") Console.WriteLine(" p - Show Properties") Console.WriteLine(" e - Show Events") Console.WriteLine(" m - Show Methods") Console.WriteLine(" a - Show All Info") Console.WriteLine(" l - Show Module Information") Console.WriteLine(" where MiscOptions") Console.WriteLine(" v = Verbose") Console.WriteLine(" r = For every type find display base type information") Console.WriteLine(" ? = Prints Usage information") Console.WriteLine() Console.WriteLine("Examples") Console.WriteLine() Console.WriteLine(" FindType String") Console.WriteLine(" Finds all types that have 'String' as part of their type name" & Chr(10)) Console.WriteLine(" FindType -r String") Console.WriteLine(" Finds all types that have 'String' as part of their name") Console.WriteLine(" and prints out all base classes" & Chr(10)) Console.WriteLine(" FindType -n System.Reflection") Console.WriteLine(" Displays all types in the 'System.Reflection' namespace" & Chr(10)) Console.WriteLine(" FindType -xipm System.String") Console.WriteLine(" Displays the interfaces, properties and methods on the 'System.String' type" & Chr(10)) Console.WriteLine(" FindType -d:C:\ -d:""C:\Program Files\Microsoft.NET\FrameworkSDK\Lib"" String") Console.WriteLine(" Searches DLLs C:\ and C:\Program Files\Microsoft.NET\FrameworkSDK\Lib") Console.WriteLine(" as well as in the current directory " & Chr(10)) Console.WriteLine() End Sub Private Shared Sub SetOptions(args As String(), ft As FindType) If CInt(args.Length) = 0 Then PrintUsage() Else Dim i As Integer ft.VerbosePrint = False Dim backslash As Char() = New Char(){"\"C} For i = 0 To CInt(args.Length) - 1 Dim j As Integer Dim curArg As String = args(i) If curArg.Chars(0) <> "-"C AndAlso curArg.Chars(0) <> "/"C Then ft.ClassAdd(curArg) ElseIf Char.ToUpper(curArg.Chars(1)) <> "D"C Then For j = 1 To curArg.Length - 1 Select Char.ToUpper(curArg.Chars(j)) Case "X"C ft.ExactMatchOnly = True Case "R"C ft.RecurseTypes = True Case "V"C ft.VerbosePrint = True Case "N"C ft.MatchOnlyNamespace = True Case "W"C ft.WideSearch = True Case "I"C ft.ShowInterfaces = True Case "M"C ft.ShowMethods = True Case "F"C ft.ShowFields = True Case "P"C ft.ShowProperties = True Case "E"C ft.ShowEvents = True Case "L"C ft.ShowModuleInfo = True Case "A"C ft.ShowAll() Case "?"C PrintUsage() Case "D"C Console.WriteLine("Directory not specified") Case Else Console.WriteLine("Invald Option[{0}]", curArg.Chars(j)) End Select Next j ElseIf curArg.Length > 2 AndAlso curArg.Chars(2) = ":"C Then Dim dir As String = curArg.Substring(3).TrimEnd(backslash).ToUpper() If dir <> "" Then ft.DirAdd(dir) Else Console.WriteLine("Directory not specified") End If Else Console.WriteLine("Directory not specified") End If Next i End If End Sub End Class