Click here to Skip to main content
15,906,816 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
GeneralRe: class XXX and class XXXImpl Pin
led mike27-May-08 9:47
led mike27-May-08 9:47 
GeneralRe: class XXX and class XXXImpl Pin
Pete O'Hanlon27-May-08 10:01
mvePete O'Hanlon27-May-08 10:01 
GeneralRe: class XXX and class XXXImpl Pin
led mike27-May-08 10:19
led mike27-May-08 10:19 
GeneralRe: class XXX and class XXXImpl Pin
Mark Churchill9-Jun-08 18:21
Mark Churchill9-Jun-08 18:21 
AnswerRe: class XXX and class XXXImpl PinPopular
Shog925-May-08 11:54
sitebuilderShog925-May-08 11:54 
GeneralRe: class XXX and class XXXImpl Pin
Scott Dorman25-May-08 12:36
professionalScott Dorman25-May-08 12:36 
GeneralRe: class XXX and class XXXImpl Pin
Shog925-May-08 12:47
sitebuilderShog925-May-08 12:47 
GeneralRe: class XXX and class XXXImpl Pin
Scott Dorman25-May-08 14:12
professionalScott Dorman25-May-08 14:12 
GeneralRe: class XXX and class XXXImpl Pin
Ahmed Charfeddine26-May-08 23:23
Ahmed Charfeddine26-May-08 23:23 
GeneralRe: class XXX and class XXXImpl Pin
Mark Churchill9-Jun-08 18:20
Mark Churchill9-Jun-08 18:20 
QuestionAdvice on Architecture for customized application Pin
ruben ruvalcaba20-May-08 4:20
ruben ruvalcaba20-May-08 4:20 
AnswerRe: Advice on Architecture for customized application Pin
Mycroft Holmes23-May-08 1:13
professionalMycroft Holmes23-May-08 1:13 
GeneralRe: Advice on Architecture for customized application Pin
ruben ruvalcaba23-May-08 4:47
ruben ruvalcaba23-May-08 4:47 
AnswerRe: Advice on Architecture for customized application Pin
Scott Dorman25-May-08 2:19
professionalScott Dorman25-May-08 2:19 
GeneralRe: Advice on Architecture for customized application Pin
ruben ruvalcaba26-May-08 4:46
ruben ruvalcaba26-May-08 4:46 
GeneralRe: Advice on Architecture for customized application Pin
Scott Dorman26-May-08 5:09
professionalScott Dorman26-May-08 5:09 
Question'Dynamic' String Formatting Pin
HoltDan18-May-08 15:07
HoltDan18-May-08 15:07 
My users need to be able to specify their own formatting preferences for string output.

So, either in Settings or the database or wherever, they specify a format string: "%lastName% can be reaced at %mainPhone% or %email%" to control the output of this class:

class Person
{
    string nameFirst;
    string nameLast;
    string eMail;
    List<Phone> phones;
}


(which is strictly by example - the real object network will be much larger/complicated)(and tokenizing the format string is no problem for me)

I'm wondering how to best produce the final string at runtime in a reasonably efficient manor. It's doubtful there will be more than a few hundred of these items at a time (less than a dozen most likely) and this string will be produced for tooltips, columns in grids, reports, etc. Still - while I don't have to worry about this being executed 1,000 a second - I'd like for it not to be too much of a pig. Maintainability is more of a concern.

It seems to me this is a good use for codeDOM and generating a dynamic method. When the app is loaded, it reads the configuration string and generates a method that looks

string DisplayAs()
{
   // i.e. based on the configuration string originally specified as "%lastName% can be reaced at %mainPhone% or %email%"
   string fmt = "{0} can be reached at {1} or {2}"; 

   string[] args = { nameLast, SomeMethodThatKnowsHowToDetermin_MAIN_PhoneFromList(), eMail };

   return string.Format ( fmt, args );
}

I've never used the codeDOM but I think I can manage something like this. But is this overkill or maybe there's a better way?

I could take a brute force approach and loop through whatever format string the user supplies doing string substitutions based on my list of 'keywords' (i.e. %mainPhone%) but there could easily be a dozen or so of those keywords. That seems painfully inefficient to me - but maybe not to the extent I should worry about it.

Thanks,
Dan Holt
AnswerRe: 'Dynamic' String Formatting Pin
led mike19-May-08 4:58
led mike19-May-08 4:58 
GeneralRe: 'Dynamic' String Formatting Pin
HoltDan19-May-08 5:50
HoltDan19-May-08 5:50 
GeneralRe: 'Dynamic' String Formatting Pin
led mike19-May-08 6:08
led mike19-May-08 6:08 
GeneralRe: 'Dynamic' String Formatting Pin
Roger Alsing20-May-08 4:06
Roger Alsing20-May-08 4:06 
GeneralRe: 'Dynamic' String Formatting Pin
Scott Dorman25-May-08 2:31
professionalScott Dorman25-May-08 2:31 
QuestionHelp with a inheritance best practices question Pin
turnergg18-May-08 8:20
turnergg18-May-08 8:20 
AnswerRe: Help with a inheritance best practices question Pin
led mike19-May-08 4:51
led mike19-May-08 4:51 
AnswerRe: Help with a inheritance best practices question Pin
Tim Yen24-May-08 19:40
Tim Yen24-May-08 19:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.