/// <summary> /// Converts <see cref="IBucketBoundaries"/> to Stackdriver's <see cref="BucketOptions"/>. /// </summary> /// <param name="bucketBoundaries">A <see cref="IBucketBoundaries"/> representing the bucket boundaries.</param> /// <returns><see cref="BucketOptions"/>.</returns> private static BucketOptions ToBucketOptions(this IBucketBoundaries bucketBoundaries) { // The first bucket bound should be 0.0 because the Metrics first bucket is // [0, first_bound) but Stackdriver monitoring bucket bounds begin with -infinity // (first bucket is (-infinity, 0)) var bucketOptions = new BucketOptions { ExplicitBuckets = new BucketOptions.Types.Explicit { Bounds = { 0.0 }, }, }; bucketOptions.ExplicitBuckets.Bounds.AddRange(bucketBoundaries.Boundaries); return(bucketOptions); }
public static IServiceCollection InitDI(this IServiceCollection services, IConfiguration configuration) { services.ConfigureMRToken(configuration, "TokenOptions"); services.ConfigurateMRIdentity <User, RepositoryUser, ManagerUser>(configuration, "MongoDatabaseConnection", options => { options.Password.RequireDigit = false; options.Password.RequiredLength = 8; options.Password.RequireLowercase = false; options.Password.RequireNonAlphanumeric = false; options.SignIn.RequireConfirmedEmail = false; options.SignIn.RequireConfirmedPhoneNumber = false; options.Tokens.AuthenticatorTokenProvider = JwtBearerDefaults.AuthenticationScheme; }); services.Scan(scan => { scan .FromAssemblyOf <IRepositoryProvider>() .AddClasses() .AsSelf() .WithTransientLifetime() .FromAssemblyOf <RepositoryProvider>() .AddClasses() .AsImplementedInterfaces() .WithTransientLifetime() .FromAssemblyOf <Manager>() .AddClasses() .AsImplementedInterfaces() .WithTransientLifetime() .FromAssemblyOf <RepositoryRole>() .AddClasses() .AsSelf() .WithTransientLifetime(); }); // connectors var bucketImageDOptions = new BucketOptions(); configuration.Bind("DBucketOptions", bucketImageDOptions); services.AddTransient <ConnectorBucketImageD>(x => new ConnectorBucketImageD(Options.Create(bucketImageDOptions))); var bucketImageROptions = new BucketOptions(); configuration.Bind("RBucketOptions", bucketImageROptions); services.AddTransient <ConnectorBucketImageR>(x => new ConnectorBucketImageR(Options.Create(bucketImageROptions))); services.Configure <EmailServiceOptions>(options => configuration.GetSection("EmailService").Bind(options)); services.Configure <RabbitOptions>(options => configuration.GetSection("Rabbit").Bind(options)); services.AddTransient <ITemplateBuilder, TemplateBuilder>(); services.AddTransient <EmailSender>(); // loggers var awsLogOptions = new AwsLogOptions(); configuration.Bind("AwsLogOptions", awsLogOptions); var loggingConfig = new LoggingConfiguration(); var awsTarget = new AWSTarget { Name = "aws", LogGroup = awsLogOptions.TargetGroup, Region = awsLogOptions.Region, Credentials = new BasicAWSCredentials(awsLogOptions.AccessKey, awsLogOptions.SecretKey), Layout = "[${longdate}] (${callsite}) ${newline} ${aspnet-mvc-controller}/${aspnet-mvc-action}/${aspnet-request} ${newline} ${aspnet-user-identity} ${newline} ${level} : ${message} ${exception:format=tostring}" }; LogManager.Configuration.AddTarget(awsTarget); LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, awsTarget)); return(services); }
public ConnectorBucket(IOptions <BucketOptions> optoins) { _options = optoins.Value; }