Re: Want function or class that uses reflection to iterate over properties in custom object

Tech-Archive recommends: Fix windows errors by optimizing your registry




Why don't you use the debugger instead of writing debug code. The
debugger will let you see the value of objects, properties, variables
etc at run time. No need to over-complicate things with writing a
reflection class.



kenfine@xxxxxxxxxxxxx wrote:
> I'm writing web applications. I build and extend a lot of custom objects,
> and in the course of debugging my apps I invariably find myself writing a
> lot of junky code:
>
> Response.Write("Title: " + uwtm.Title + "<br>");
> Response.Write("Pubdate: " + uwtm.Pubdate + "<br>");
> Response.Write("Byline String: " + uwtm.Byline + "<br>");
> Response.Write("Order (converted): " + uwtm.Order + "<br>");
> Response.Write("Body:" + uwtm.Body + "<br>");
> Response.Write("CategoryId: "+ uwtm.CategoryId + "<br>");
>
> I am lazy and would prefer not to write error-prone code like this. It would
> also be nice to be able to discover these properies at runtime and do useful
> things. I've learned that you can do this using reflection. Hoping someone
> can help me with a few questions:
>
> 1) Surely someone has put together a function or class that will take an
> object and dump properties and property labels. Can someone offer me code or
> a link? Remember that I'm building asp.net apps, not windows forms.
>
> 2) Must my custom objects implement IEnumerable for 1) to happen, or is this
> baked in?
>
> 3) Does anyone know of the best comprehensive newbie introduction to
> reflection? I can buy a book if necessary.
>
> Thank you,
> Ken Fine

.



Relevant Pages

  • Re: DPMI raw mode switch
    ... > 2F, and since that's how you begin any startup procedure with DPMI, it ... when writing DOS software I ... use the WD (Watcom Debugger) from the WATCOM C++ 11.0c compiler package. ...
    (alt.lang.asm)
  • Re: getting good at assembly language
    ... Ludwig wrote the following useful and helpful info - ... And writing assembly entices to get dirty in your code ... >> Again true, a debugger would require a lot of good OS knowledge, ... Thanks for that, maybe I will aim towards a kernel debugger, I've ...
    (alt.lang.asm)
  • Re: Top ten errors
    ... >> But the debugger issue hits one of my buttons. ... > writing functions or code snippets which are to be removed in the final ... thrown away (yes, even 'correct', working code). ... was the learning experience, not the code itself. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: getting good at assembly language
    ... > writing such tools I don't think allows for sloppy design or coding ... > Again true, a debugger would require a lot of good OS knowledge, ... writing something like www.ollydbg.de is ... > need to ease myself in gently by getting stuck into assembler once ...
    (alt.lang.asm)
  • Re: edit & continue
    ... restarting the whole app than trying to jump back that far(if its even ... > check it for mistakes is to run it. ... I simply said I don't use the debugger enough to ... they are writing, catching the little mistakes that are left behind. ...
    (microsoft.public.dotnet.languages.csharp)