examinedliving
9/29/2019 - 1:03 PM

GetPropertyVaules

Uses reflection to Get Class Instance Properties give "obj" is instance of class, returns a JSON key-value string of all properties of class.

		Public Function GetPropertyValues(obj As Object) As String

			Dim json As JObject = JObject.Parse("{}")
			Dim t As Type = obj.GetType()
			Dim props() As Reflection.PropertyInfo = t.GetProperties()

			For Each prop In props
				If prop.GetIndexParameters().Length = 0 Then
					json.Item(prop.Name) = JToken.FromObject(prop.GetValue(obj, Nothing))
				End If
			Next
			Return JsonConvert.SerializeObject(json, New Converters.KeyValuePairConverter())
		End Function