Re: Replacing marked values in a text file

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Razzie (razzie_at_quicknet.nl)
Date: 08/25/04


Date: Wed, 25 Aug 2004 19:43:05 +0200

So I guess I'll have to look for RegEx but especially reflection. Ok thanks
all!

"Razzie" <razzie@quicknet.nl> wrote in message
news:%23ne4Z7riEHA.3972@tk2msftngp13.phx.gbl...
> Hey all,
>
> Let's say I have a textfile with 'marked' values in it, for example,
> something like this:
>
> Name......... *name*
> Street......... *street*
> Email.......... *email*
>
> And say I have 1 or more objects with properties equal to the name of
> those marked values, for example:
>
> Person.name, Person.street, Person.email
>
> well you get the idea :)
> Now, I want to replace the * * values in the textfile with the properties
> of the object. Of course this ain't a problem, however, I do NOT want the
> following situation:
>
> //Search the file for a * * string
> switch(strToReplace)
> {
> case "*name*":
> // replace strToReplace with Person.name
> break;
> case "*street*":
> // replace strToReplace with Person.street
> break;
> // etc
> }
>
> this code just looks plain ugly to me and besides, if I get like 100+ * *
> values in my (more than 1) textfiles, which is quite possible, this is a
> lot of work too. I'm hoping for a very easy and clean way instead... is
> there a way to call the corresponding property automatically when the
> names are equal? Is there another way to do this? I've been looking for a
> solution using design patterns but I couldn't find a good one, so I hope
> someone here knows a good solution.
>
> THanks a lot in advance,
>
> Razzie
>
>



Relevant Pages