Delegates mod

Jun 14, 2011 at 1:33 PM

Great tool, both in idea and execution.

I'm trying to mod it a little so that I can create delegates for strings.

To explain: I have a function that takes a string as an argument. And I want this function to only accept localized strings, and for non-localized strings to fail at compile time.

So, this code should not compile:

Printer.Print( "I'm a developer who didn't know we're using localized strings" );

What would be cool is if I could define my helper function something like this:

public delegate string LocalizedStringFunction ();
static void Print ( LocalizedStringFunction func ) 

and then the user would have to do something like this

Printer.Print( LocalizedString.ObliviousProgrammer );

(yes, they could pass in any function without arguments returning a string, but they are unlikely to do this by accident)

It's a bit of a tricky mod though as even if I convert your code to output all the resource strings as functions (instead of properties), the parameters of those functions will depend on their formatting.

Any advice?

Thanks for the tool as is though!