Пример #1
0
        public async Task SendAsync <TSubject, TBody>(IEmail <TSubject, TBody> email)
            where TSubject : IEmailSubject
            where TBody : IEmailBody
        {
            if (email == null)
            {
                throw new ArgumentNullException(nameof(email));
            }

            EmailBouncer
            .Validate((IEmail <IEmailSubject, IEmailBody>)email)
            .ThrowIfInvalid();

            try
            {
                await SendAsyncCore(email);
            }
            catch (Exception innerException)
            {
                throw DynamicException.Factory.CreateDynamicException(
                          $"SendEmail{nameof(Exception)}",
                          $"Could not send email: Subject = '{email.Subject}' To = '{email.To}' From = '{email.From}'.",
                          innerException
                          );
            }
        }
Пример #2
0
        public ILoggerFactory Build()
        {
            SelfBouncer.Validate(this);

            return(new LoggerFactory
            {
                Observers = _rxes,
                Configuration = new LoggerFactoryConfiguration
                {
                    Attachements =
                    {
                        new OmniLog.Attachements.Lambda("Environment",           _ => _environment),
                        new OmniLog.Attachements.Lambda("Product",               _ => _product),
                        new OmniLog.Attachements.Timestamp <DateTimeUtc>(),
                        new OmniLog.Attachements.Scope(new JsonSerializer {
                            Settings = _scopeSerializerSettings
                        }),
                        new OmniLog.Attachements.ElapsedMilliseconds("Elapsed"),
                        new OmniLog.SemanticExtensions.Attachements.Snapshot(new JsonSerializer {
                            Settings = _snapshotSerializerSettings
                        })
                    }
                }
            });
        }
Пример #3
0
 public static BouncerPolicyCheckLookup <T> ValidateWith <T>([NotNull] this T value, [NotNull] IBouncer <T> bouncer) => bouncer.Validate(value);