Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 809587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:45:04+00:00 2026-05-15T00:45:04+00:00

I am building a helper object that has a property called Mailer. In reality

  • 0

I am building a helper object that has a property called Mailer. In reality Mailer can be either a System.Net.Mail.MailMessage or a Mono.System.Net.Mail.MailMessage. So I would preferably only want 1 declaration of mailer.

For example I don’t want:

private Mono.Mailing.MailMessage MonoMessage = new Mono.Mailing.MailMessage();
private System.Net.Mail.MailMessage MailMessage = new System.Net.Mail.MailMessage();

I would prefer

object mailer;

Then in constructor

switch (software)
            {
                case EnunInternalMailingSoftware.dotnet:
                    this.mailer = new System.Net.Mail.MailMessage();
                    break;
                case EnunInternalMailingSoftware.mono:
                    this.mailer = new Mono.Mailing.MailMessage(); 
                    break;
            }

The problem is that mailer has no properties at design time. So I can’t compile my code.

How can this be fixed, am I taking the right approach. Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T00:45:04+00:00Added an answer on May 15, 2026 at 12:45 am

    You should use the adapter pattern for this:
    http://en.wikipedia.org/wiki/Adapter_pattern

    Define an interface that covers the methods you need (e.g. SendMail()) and then write a simple adapter class for each MailMessage object that implements the interface and delegates to the correct methods on the specific MailMessage class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this helper that I am building: def myhelper(object, attributes = []) attributes.each
Building a website that has English & Japanese speaking users, with the Japanese users
I am building an ASP.NET web service that will be used internally in my
I'm building a simple game in an ASP.NET/VB.NET web app. The game has a
QQ: How can I update an object's property to match the innerHtml of an
I'm building a class project (seperate dll) that will contain various helper methods and
I am building a custom HTML.LabelFor helper that looks like this : public static
I'm having an issue with building a Javascript object, and calling methods within that
I have a system I'm building that seems to call for some complex rules
I am building a helper class that would allow me to manage facebook account

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.