I am trying to recreate a outlook/exchange mailbox in our application and I am in the early stages building the models. However, I am coming across something that is making me question if a model can be dynamic enough to contain itself. The issues comes up for the folder class which can contain emails or more folders:
public class Mailbox
{
public List<Folder> Folders {get; set;} = new List<Folder>();
}
public class Folder
{
public List<Folder> Folders {get; set;} = new List<Folder>();
public List<Email> Emails {get; set;} = new List<Email>();
}
public class Email
{
public string Id {get; set;}
public Contact From { get; set; }
public List<Contact>? To { get; set; } = new List<Contact>();
public List<Contact>? Cc { get; set; } = new List<Contact>();
public List<Contact>? Bcc { get; set; }
public string Subject { get; set; } = "";
public string Body { get; set; } = "";
public List<FileAttachment>? FileAttachments { get; set; } = new List<FileAttachment>();
public DateTime ReceivedDate {get; set;}
}
public class Contact
{
[EmailAddress]
public required string EmailAddress { get; set; }
public string? FirstName {get; set;}
public string? LastName {get; set;}
}
public class FileAttachment
{
public string Id {get; set;}
public MemoryStream File {get; set;}
public string FileName { get; set; }
public string ContentType { get; set; }
public byte[] ContentBytes { get; set; }
}
Is this allowable? What issues will I run into because its not tripping any errors and compiles but something doesn’t seem correct about this.