GPPointFileInfo\ObjectToString.vb
Creating a non-trival custom GP tool - inputs, outputs, and responding to environment settings
GPPointFileInfo\ObjectToString.vb
' Copyright 2008 ESRI
' 
' All rights reserved under the copyright laws of the United States
' and applicable international laws, treaties, and conventions.
' 
' You may freely redistribute and use this sample code, with or
' without modification, provided you include the original copyright
' notice and use restrictions.
' 
' See use restrictions at <your ArcGIS install location>/developerkit/userestrictions.txt.
' 

Imports Microsoft.VisualBasic
Imports System.Reflection
Imports System
Imports System.Diagnostics

Namespace GPPointFileInfo
    Public Class ObjectToString
        Private Sub New()
        End Sub
        Public Shared Function GetToString(ByVal o As Object) As String
            Dim toString As String = o.ToString() & Constants.vbLf

            Dim propertyInfoArray As PropertyInfo() = o.GetType().GetProperties()

            For Each propertyInfo As PropertyInfo In propertyInfoArray
                Try
                    toString &= propertyInfo.Name & " = " & propertyInfo.GetValue(o, Nothing).ToString + Constants.vbLf
                Catch ex As Exception
                    Trace.WriteLine(ex)
                End Try
            Next propertyInfo

            toString &= Constants.vbLf

            Return toString
        End Function

        Public Shared Function GetNewline() As String
            Const Newline As String = Constants.vbLf

            Return Newline & Newline
        End Function
    End Class
End Namespace