Letters from Readers

Letters: Looking into Lambdas

C# Corner columnist Patrick Steele recently explored the idea of using lambda methods as a way to plug in specific functionality with more control than subclassing ("Lambda Properties: An Alternative to Subclassing?" June 2011). Readers respond:

I think this is a great idea for those edge instances where you need a slight variation for one or two places in the code and creating an entire subclass is more work than it's worth.

Sean Cooper
Chicago, Ill.

I agree with Sean. While you wouldn't want to replace inheritance with this approach, I can see the power of it. It's certainly something that I'll keep in mind as I develop -- especially when writing unit tests. Thanks!

Reese
Spokane, Wash.

I would opt for creating methods that take a Func as a parameter. This is an example of the Strategy pattern.

Robert Zurer
New York, NY

Missing Tools
What about NuGet? And ReSharper [missing from the June 2011 "Visual Studio Toolapalooza"]?

Bill Mild

Peter Vogel responds: I'm a big fan of ReSharper, but it doesn't have a free version (at least, not one I could find). And I was going to include NuGet, but Ian Davis beat me to it in his recent Open Source .NET column online. So I was out of luck. They're still great tools, though.

If you just want to dump the e-mail to a folder, you don't need a program to do that. Just set the SmtpClient's DeliveryMethod property to SpecifiedPickupDirectory, and set the PickupDirectoryLocation property to the path where you want the files to be generated. (You can even do this in the config file for a no-code change.) The generated files will be standard EML files, which you can open with Outlook Express or Windows Live Mail.

Richards

Peter Vogel responds: There's nothing wrong with setting the DeliveryMethod property -- provided, of course, you remember to change the setting before releasing to production (let's not ask why I know this). But I still need to either use some client to view the mail or find my way to the folder to check my results. The nice thing about tools like papercut and smtp4dev is that they come with a client and the client sits right in the tray, making it easy to see my results.

About the Author

This story was written or compiled based on feedback from the readers of Visual Studio Magazine.

comments powered by Disqus

Featured

Subscribe on YouTube