Пример #1
0
        protected virtual Task LocalizeAsync(EmailTemplateDefinition emailTemplateDefinition,
                                             EmailTemplate emailTemplate, string cultureName)
        {
            if (emailTemplateDefinition.LocalizationResource == null)
            {
                return(Task.CompletedTask);
            }

            var localizer = StringLocalizerFactory.Create(emailTemplateDefinition.LocalizationResource);

            if (cultureName != null)
            {
                emailTemplate.SetContent(
                    TemplateLocalizer.Localize(localizer.WithCulture(new CultureInfo(cultureName)),
                                               emailTemplate.Content)
                    );
            }
            else
            {
                emailTemplate.SetContent(
                    TemplateLocalizer.Localize(localizer, emailTemplate.Content)
                    );
            }

            return(Task.CompletedTask);
        }
Пример #2
0
        protected virtual async Task SetLayoutAsync(EmailTemplateDefinition emailTemplateDefinition,
                                                    EmailTemplate emailTemplate, string cultureName)
        {
            var layout = emailTemplateDefinition.Layout;

            if (layout.IsNullOrWhiteSpace())
            {
                return;
            }

            if (layout == EmailTemplateDefinition.DefaultLayoutPlaceHolder)
            {
                layout = Options.DefaultLayout;
            }

            var layoutTemplate = await GetInternalAsync(layout, cultureName);

            emailTemplate.SetLayout(layoutTemplate);
        }
Пример #3
0
 public EmailTemplate(string content, EmailTemplateDefinition definition)
 {
     ContentBuilder = new StringBuilder(content);
     Definition     = definition;
 }
 public EmailTemplateInitializationContext(EmailTemplateDefinition emailTemplateDefinition,
                                           IServiceProvider serviceProvider)
 {
     EmailTemplateDefinition = emailTemplateDefinition;
     ServiceProvider         = serviceProvider;
 }