Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing IEnumerable<> and creating a property with its type
    primarykey
    data
    text
    <p>I have not used Linq much nor have I used the IEnumberable class. Below is my code and explanations on what I am having trouble with.</p> <pre><code>public class EmailService : IEmailService { #region Constructors #endregion #region Properties [ImportMany] public IEnumerable&lt;IEmailAddressesProvider&gt; AddressProviders { get; set; } #endregion </code></pre> <p>These are my properties that I need to use in the EmailService Class. This is a collection of the email address providers.</p> <p>I need to use what is stored there in and basically connect it to the ViewModel as I did with these other properties in the next section of this code.</p> <pre><code>IUserInteractionService uiService = AllianceApp.Container.GetExportedValue&lt;IUserInteractionService&gt;(); IEmailSetupProvider provider = new EmailSetupProvider(); EmailView ev = AllianceApp.Container.GetExportedValue&lt;EmailView&gt;(); ev.ViewModel.ProviderName = AddressProviders; ev.ViewModel.Provider = provider; ev.ViewModel.Bcc = bccAddress; ev.ViewModel.Cc = ccAddress; ev.ViewModel.ToAddress = toAddress; ev.ViewModel.Body = body; ev.ViewModel.Subject = subject; ev.ViewModel.Attachments = attachments; return uiService.ShowDialog(ev, RegionNames.MainRegion); } </code></pre> <p>Where it says "Address Providers is where I am trying to create this property.</p> <p>IEmailAddressesProvider Interface:</p> <pre><code>public interface IEmailAddressesProvider { string ProviderName { get; } IEnumerable&lt;EmailAddress&gt; GetEmailUsers(); } </code></pre> <p>GetEmailUsers Method(Just in case it is relevant):</p> <pre><code>[Export(typeof(IEmailAddressesProvider))] public class EmailAddressProvider : IEmailAddressesProvider { #region Private Properties private static readonly IEncryptionService encryptionService = AllianceApp.Container.GetExportedValue&lt;IEncryptionService&gt;(); #endregion public string ProviderName { get { return "Alliance Users"; } } public IEnumerable&lt;EmailAddress&gt; GetEmailUsers() { IUserRepository userRepo = AllianceApp.Container.GetExportedValue&lt;IUserRepository&gt;(); IEnumerable&lt;User&gt; users = userRepo.GetAllUsers().Where(a =&gt; a.IsDeleted == false).OrderBy(a =&gt; a.UserID).AsEnumerable(); List&lt;EmailAddress&gt; AddressList = new List&lt;EmailAddress&gt;(); foreach (var user in users) { if (user.DisplayName != null &amp;&amp; user.EmailAddress != null &amp;&amp; user.DisplayName != string.Empty &amp;&amp; user.EmailAddress != string.Empty) AddressList.Add(new EmailAddress() { DisplayName = encryptionService.DecryptString(user.DisplayName), Email = encryptionService.DecryptString(user.EmailAddress) }); } AddressList.OrderBy(u =&gt; u.DisplayName); return AddressList; } } </code></pre> <p>Code specifically for ProviderName (used in EmailAddressesProvider.cs):</p> <pre><code>[Export(typeof(IEmailAddressesProvider))] public class EmailAddressProvider : IEmailAddressesProvider { #region Private Properties private static readonly IEncryptionService encryptionService = AllianceApp.Container.GetExportedValue&lt;IEncryptionService&gt;(); #endregion public string ProviderName { get { return "Alliance Users"; } } } </code></pre> <p>If you need to see anymore of my code, such as the interfaces or the viewmodel, please let me know. Any help would be appreciated!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload