[...]
Why ask a question like this and then answer it in the very next
paragraph? It makes it look like you a re trying to be contrary simply
to show-off.
A belligerent attitude is not a very good way to solicit help.
For the record, I asked the question because I felt it would solicit
information that could be useful in understanding _your_ question better.
No other motivation was involved, and it's counter-productive for you to
waste time insulting me or inferring anything other than that from my
question.
How is my telling you that you "look like you are trying to be
contrary" different than you telling me flat out that I am
belligerent? I was not meaning to be belligerent, I was simply
notifying you that when you post the statements you do it looks a
particular way. I apologize if this offended you.
What makes you think I don't understand this?
Because your original question was vague and failed to convey what about
the problem you're actually having trouble with.
Anyway, if you had tried
this in code you would realize that strings have properties too and
then they get "decomposed" to Length and Char[] properties. Which then
get broken down into individual characters which would not do for
logging at all.
What makes you think I don't understand this?
Because it seems completely untenable to have a log file of single
chars and it didn't seem to me that you realized that the practical
upshot of what you were suggesting didn't fit the "I'm logging object
values" part of my question. I guess your log files look different
than my log files.
I specifically broke my answer into two parts; a high-level description of
the basic idea, and then a discussion of the details involved. Because
your original question was so vague, it was necessary to set a framework
within which _any_ answer could be written. That includes a clear
statement that at the highest-level, it appears you are looking for some
kind of recursive implementation. You didn't provide the statement, soI
did.
For you to become belligerent about that makes no sense. It's almost like
you don't really want anyone to help you at all. All I'm trying to do is
provide some clarity to a question that wasn't clear at all.
Again, I wasn't tying to be belligerent. I was responding to the
insinuation that I had not thought of the answer. A simple response of
"Because you didn't say anything about it in your question" would have
sufficed. And you are right.
[...]
Not recursing at all would output the following for my example:
"FName: FirstName"
"LName: LastName"
"PersonAddress: WindowsFormsApplication1.Address"
Which, it should be obvious, is no help.
Why should that be obvious? There's nothing in your queston that would
allow for a complete understanding of what you really want, never mind any
insight as to what pragmatic concessions to the problem you're willing to
make in order to deal with some of the pracical problems that exist.
Pete
It should be obvious because I state at the beginning of the question
that I am logging object values. "WindowsFormsApplication1.Address" is
not an object value, it's an object Type and therefore obviously not
what I want to log.
OK, so to restate the question in a more complete form:
I am logging variable values to a file. I am trying to make the
logging as generic as I can. I'd like a simple method that will accept
an "object" and write the values of each of the Properties (and
Fields) to the log mechanism. I am currently using a recursive method
that accepts an object and then gets all the properties and itterates
through them. It will call itself on any properties of those
properties. For information sake I am determining if the property is
an array or not and applying GetValue appropriately. The problem I
have is determining the difference between String or DateTime
variables (where I don't want to recurse further) and other custom
class variables (where I do want to recurse further).
I hope this is better.
Tom P.