我正在使用COM在C++和C#之间进行通信。
我在C#中有以下类:
Email Address
/// <summary> /// Email Address /// </summary> public class EmailAddress { /// <summary> /// SMTP Address /// </summary> [MarshalAs(UnmanagedType.BStr)] public string Address; /// <summary> /// Name /// </summary> [MarshalAs(UnmanagedType.BStr)] public string Name; }
Mailbox
/// <summary> /// MailBox Entity /// </summary> public struct MailBoxEntity { /// <summary> /// SMTP Address /// </summary> [MarshalAs(UnmanagedType.BStr)] public string SMTPAddress; /// <summary> /// Mailbox Display Name /// </summary> [MarshalAs(UnmanagedType.BStr)] public string Name; /// <summary> /// Mailbox Server Name /// </summary> [MarshalAs(UnmanagedType.BStr)] public string sServerName; }
EmailEntity (yet to implement IEmailEntity which will contain properties for each field)
/// <summary> /// Class for Email Entity /// </summary> public class EmailEntity : IEmailEntity { /// <summary> /// BccRecipients /// </summary> [MarshalAs(UnmanagedType.ByValArray)] public EmailAddress[] BccRecipients; /// <summary> /// Body /// </summary> [MarshalAs(UnmanagedType.BStr)] public string Body; /// <summary> /// CcRecipients /// </summary> [MarshalAs(UnmanagedType.ByValArray)] public EmailAddress[] CcRecipients; /// <summary> /// Culture /// </summary> [MarshalAs(UnmanagedType.BStr)] public string Culture; /// <summary> /// DateTimeCreated /// </summary> [MarshalAs(UnmanagedType.BStr)] public string DateTimeCreated; /// <summary> /// DateTimeReceived /// </summary> [MarshalAs(UnmanagedType.BStr)] public string DateTimeReceived; /// <summary> /// DateTimeSent /// </summary> [MarshalAs(UnmanagedType.BStr)] public string DateTimeSent; /// <summary> /// FromAddress /// </summary> [MarshalAs(UnmanagedType.BStr)] public string FromAddress; /// <summary> /// FromName /// </summary> [MarshalAs(UnmanagedType.BStr)] public string FromName; /// <summary> /// HasAttachments /// </summary> [MarshalAs(UnmanagedType.BStr)] public string HasAttachments; /// <summary> /// Id /// </summary> [MarshalAs(UnmanagedType.BStr)] public string Id; /// <summary> /// Importance /// </summary> [MarshalAs(UnmanagedType.BStr)] public string Importance; /// <summary> /// LastModifiedName /// </summary> [MarshalAs(UnmanagedType.BStr)] public string LastModifiedName; /// <summary> /// LastModifiedTime /// </summary> [MarshalAs(UnmanagedType.BStr)] public string LastModifiedTime; /// <summary> /// MimeContent /// </summary> [MarshalAs(UnmanagedType.BStr)] public string MimeContent; /// <summary> /// ParentFolderId /// </summary> [MarshalAs(UnmanagedType.BStr)] public string ParentFolderId; /// <summary> /// Original Mailbox /// </summary> [MarshalAs(UnmanagedType.BStr)] public MailBoxEntity OriginalMailBox; /// <summary> /// ParentFolderName /// </summary> [MarshalAs(UnmanagedType.BStr)] public string ParentFolderName; /// <summary> /// ReceivedByAddress /// </summary> [MarshalAs(UnmanagedType.BStr)] public string ReceivedByAddress; /// <summary> /// ReceivedByName /// </summary> [MarshalAs(UnmanagedType.BStr)] public string ReceivedByName; /// <summary> /// Size /// </summary> [MarshalAs(UnmanagedType.BStr)] public string Size; /// <summary> /// Subject /// </summary> [MarshalAs(UnmanagedType.BStr)] public string Subject; /// <summary> /// ToRecipients /// </summary> [MarshalAs(UnmanagedType.ByValArray)] public EmailAddress[] ToRecipients; }
我该如何访问C++中复杂的字段成员,比如EmailAddress(EmailAddress[] ToRecipients)数组。
请给出建议。
谢谢。