Inheritance - System.Net.Mail namespace

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Prefers Golfing

    Inheritance - System.Net.Mail namespace

    We are having to extend the System.Net.Mail namespace and need some help
    with coding it.

    We have added several properties to System.Net.Mail .Attachment and need to
    add our several of them to System.Net.Mail .MailMessage.At tachments.

    // public AttachmentColle ction Attachments { get; }

    How do we override AttachmentColle ction to be a collection of
    OurNamespace.At tachments?

    How then do we override MailMessage to be the above collection?

    public class MailMessage : System.Net.Mail .MailMessage

    {

    public MailMessage()

    {

    }


    private int _shipmentID;

    public int ShipmentID

    {

    get { return _shipmentID; }

    set { _shipmentID = value; }

    }

    private int _shipmentEmails ID;

    public int ShipmentEmailsI D

    {

    get { return _shipmentEmails ID; }

    set { _shipmentEmails ID = value; }

    }

    // overide attachments

    public override ?

    }

    public class Attachment : System.Net.Mail .Attachment

    {private int _documentsID;

    public int DocumentsID

    {

    get { return _documentsID; }

    set { _documentsID = value; }

    }

    }


  • Ignacio Machin ( .NET/ C# MVP )

    #2
    Re: Inheritance - System.Net.Mail namespace

    On Aug 1, 3:34 pm, "Prefers Golfing" <prefersgolf... @gmail.comwrote :
    We are having to extend the System.Net.Mail namespace and need some help
    with coding it.
    >
    We have added several properties to System.Net.Mail .Attachment and need to
    add our several of them to System.Net.Mail .MailMessage.At tachments.
    >
    // public AttachmentColle ction Attachments { get; }
    >
    How do we override AttachmentColle ction to be a collection of
    OurNamespace.At tachments?
    you can't Attachments is not a virtual member in MailMessage.
    What this means is that if you pass an instance of your new class to a
    method that use a MailMessage it will use MailMessage's member, not
    yours.

    If you will use your class only with your new classes then you are ok,
    just define Attachments in the same way.

    Comment

    • =?ISO-8859-1?Q?Arne_Vajh=F8j?=

      #3
      Re: Inheritance - System.Net.Mail namespace

      Prefers Golfing wrote:
      We are having to extend the System.Net.Mail namespace and need some help
      with coding it.
      >
      We have added several properties to System.Net.Mail .Attachment and need to
      add our several of them to System.Net.Mail .MailMessage.At tachments.
      >
      // public AttachmentColle ction Attachments { get; }
      >
      How do we override AttachmentColle ction to be a collection of
      OurNamespace.At tachments?
      >
      How then do we override MailMessage to be the above collection?
      I think we have a classic case of trying to extend classes that
      were not intended to be extended.

      Or to put it another way: I think you need to either live with
      the standard .NET functionality or implement your own mail
      framework from scratch (the protocols are reasonable simple
      to implement).

      Arne

      Comment

      Working...