コード例 #1
0
        /// <summary>
        ///     Handles the Start event of the Application control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void Application_Start(object sender, EventArgs e)
        {
            var modules =
                new IContainerModule[]
            {
                new AdContainerModule(),
                new CommonContainerModule(),
                new EnginesContainerModule(),
                new CommonPluginsContainerModule(),
                new PluginsContainerModule(),
                new RepositoryContainerModule(),
                new CoreContainerModule(),
                new QueryContainerModule(),
                new EnginesDslModule(),
                new InfrastructureContainerModule(),
                new UserInterfaceInfrastructureContainerModule(),
                new PackagesContainerModule(),
                new DbMigrationsModule(),
                new DbUpdateCommonModule(),
                new DbActionsModule(),
                new RequestHandlingModule(),
                new ReportContainerModule(),
                new RulesContainerModule(),
                new NotificationsContainerModule(),
                new WorkflowContainerModule(),
                new ScanWorkflowModule(),
                new SchedulerContainerModule(),
                new GitHubWorkflowContainerModule()
            };

            IoC.InitDefault(ReuseScope.PerRequest, modules);

            var globalContainer = IoC.GetContainer();

            var migrator = globalContainer.Resolve <IDbMigrator>();

            migrator.MigrationLatest();

            EnvironmentInitializer.Initialize(
                modules,
                ReuseScope.Container,
                container =>
            {
                var env = container.Resolve <IEnvironmentProvider>();

                env.Prepare();
            });

            _schedulerContainer = EnvironmentInitializer.InitializeContainer(modules, ReuseScope.Hierarchy);
            JobScheduler        = _schedulerContainer.Resolve <IJobScheduler>();
            JobScheduler.Start(true);

            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
        }
コード例 #2
0
    private void SpawnNext()
    {
        if (_nextSpawned)
        {
            return;
        }
        _nextSpawned = true;
        var newPos = GetComponentInParent <EnvironmentInitializer>().transform.position - new Vector3(EnvironmentPrefabLength, 0, 0);

        newObj = Instantiate(EnvironmentInitPrefab, newPos, Quaternion.identity);
        newObj.Spawn(this);
    }
コード例 #3
0
        public Dashboard()
        {
            InitializeComponent();
            EnvironmentInitializer.CheckAndInitializeSQLiteDB();
            SampleData.AddSampleData();

            using (var dbcontext = new WarehouseContext())
            {
                var query = dbcontext.Database.SqlQuery <User>("select * from Users where Name like @p0", "%二%");
                var list  = query.ToList();
            }
        }
コード例 #4
0
 internal SimpleFunctionResolver(EnvironmentInitializer initializer)
 {
     _environmentInitializer = initializer;
 }
コード例 #5
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to add services to the container.
        /// </summary>
        /// <param name="services">An instance of <see cref="IServiceCollection"/>.</param>
        public void ConfigureServices(IServiceCollection services)
        {
            this.ConfigureServicesCommon(services);

            _ = services.AddMvc();
            _ = services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "NotificationService", Version = "v1"
                });
            });

            ITelemetryInitializer[] itm = new ITelemetryInitializer[1];
            var envInitializer          = new EnvironmentInitializer
            {
                Service         = this.Configuration[AIConstants.ServiceConfigName],
                ServiceLine     = this.Configuration[AIConstants.ServiceLineConfigName],
                ServiceOffering = this.Configuration[AIConstants.ServiceOfferingConfigName],
                ComponentId     = this.Configuration[AIConstants.ComponentIdConfigName],
                ComponentName   = this.Configuration[AIConstants.ComponentNameConfigName],
                EnvironmentName = this.Configuration[AIConstants.EnvironmentName],
                IctoId          = "IctoId",
            };

            itm[0] = envInitializer;

            NotificationProviders.Common.Logger.LoggingConfiguration loggingConfiguration = new NotificationProviders.Common.Logger.LoggingConfiguration
            {
                IsTraceEnabled  = true,
                TraceLevel      = (SeverityLevel)Enum.Parse(typeof(SeverityLevel), this.Configuration[ConfigConstants.AITraceLelelConfigKey]),
                EnvironmentName = this.Configuration[AIConstants.EnvironmentName],
            };

            var tconfig = TelemetryConfiguration.CreateDefault();

            tconfig.InstrumentationKey = this.Configuration[ConfigConstants.AIInsrumentationConfigKey];

            DependencyTrackingTelemetryModule depModule = new DependencyTrackingTelemetryModule();

            depModule.Initialize(tconfig);

            RequestTrackingTelemetryModule requestTrackingTelemetryModule = new RequestTrackingTelemetryModule();

            requestTrackingTelemetryModule.Initialize(tconfig);

            _ = services.AddSingleton <NotificationProviders.Common.Logger.ILogger>(_ => new NotificationProviders.Common.Logger.AILogger(loggingConfiguration, tconfig, itm));

            _ = services.AddScoped <IEmailManager, EmailManager>(s =>
                                                                 new EmailManager(
                                                                     this.Configuration,
                                                                     s.GetService <IRepositoryFactory>(),
                                                                     s.GetService <ILogger>(),
                                                                     s.GetService <IMailTemplateManager>(),
                                                                     s.GetService <ITemplateMerge>()))
                .AddScoped <IEmailServiceManager, EmailServiceManager>(s =>
                                                                       new EmailServiceManager(this.Configuration, s.GetService <IRepositoryFactory>(), s.GetService <ICloudStorageClient>(), s.GetService <ILogger>(),
                                                                                               s.GetService <INotificationProviderFactory>(), s.GetService <IEmailManager>()))
                .AddScoped <ITemplateMerge, TemplateMerge>()
                .AddSingleton <IEmailAccountManager, EmailAccountManager>()
                .AddScoped <INotificationProviderFactory, NotificationProviderFactory>();

            NotificationProviderType providerType = (NotificationProviderType)Enum.Parse(typeof(NotificationProviderType), this.Configuration[ConfigConstants.NotificationProviderType]);

            if (NotificationProviderType.DirectSend == providerType)
            {
                this.ConfigureDirectSendServices(services);
            }
            else if (NotificationProviderType.SMTP == providerType)
            {
                this.ConfigureSMTPServices(services);
            }
            else
            {
                this.ConfigureGraphServices(services);
            }
        }
コード例 #6
0
 public SimpleAnalysis(ControlFlowGraph.ControlFlowGraph entryCFG, Weverca.MemoryModels.MemoryModelFactory memoryModel, EnvironmentInitializer initializer)
     : base(entryCFG, memoryModel.CreateSnapshot)
 {
     _flowResolver     = new SimpleFlowResolver();
     _functionResolver = new SimpleFunctionResolver(initializer);
     initializer(EntryInput);
 }
コード例 #7
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to add services to the container.
        /// </summary>
        /// <param name="services">An instance of <see cref="IServiceCollection"/>.</param>
        public void ConfigureServicesCommon(IServiceCollection services)
        {
            _ = services.AddAzureAppConfiguration();

            _ = services.AddAuthorization(configure =>
            {
                configure.AddPolicy(ApplicationConstants.AppNameAuthorizePolicy, policy =>
                {
                    policy.Requirements.Add(new AppNameAuthorizeRequirement());
                });
                configure.AddPolicy(ApplicationConstants.AppIdAuthorizePolicy, policy =>
                {
                    policy.Requirements.Add(new AppIdAuthorizeRequirement());
                });
            });
            _ = services.AddSingleton <IAuthorizationHandler, AppNameAuthorizePolicyHandler>(s => new AppNameAuthorizePolicyHandler(s.GetService <IHttpContextAccessor>(), this.Configuration));
            _ = services.AddSingleton <IAuthorizationHandler, AppIdAuthorizePolicyHandler>(s => new AppIdAuthorizePolicyHandler(s.GetService <IHttpContextAccessor>(), this.Configuration));

            _ = services.AddControllers();

            _ = services.AddApplicationInsightsTelemetry();
            _ = services.AddScoped(typeof(ValidateModelAttribute));
            _ = services.AddOptions();

            _ = services.Configure <StorageAccountSetting>(this.Configuration.GetSection(ConfigConstants.StorageAccountConfigSectionKey));
            _ = services.Configure <StorageAccountSetting>(s => s.ConnectionString = this.Configuration[ConfigConstants.StorageAccountConnectionStringConfigKey]);
            _ = services.Configure <UserTokenSetting>(this.Configuration.GetSection(ConfigConstants.UserTokenSettingConfigSectionKey));
            _ = services.Configure <RetrySetting>(this.Configuration.GetSection(ConfigConstants.RetrySettingConfigSectionKey));

            _ = services.AddSingleton <IConfiguration>(this.Configuration);
            _ = services.AddSingleton <IEncryptionService, EncryptionService>();
            _ = services.AddSingleton <IKeyEncryptionKey, CryptographyClient>(cc => new CryptographyClient(new Uri(this.Configuration[ConfigConstants.KeyVaultRSAUriConfigKey]), new DefaultAzureCredential()));

            _ = services.AddTransient <IHttpContextAccessor, HttpContextAccessor>()
                .AddSingleton <ICloudStorageClient, CloudStorageClient>()
                .AddScoped <ITokenHelper, TokenHelper>()
                .AddScoped <IRepositoryFactory, RepositoryFactory>()
                .AddSingleton <IEmailAccountManager, EmailAccountManager>();

            StorageType storageType = (StorageType)Enum.Parse(typeof(StorageType), this.Configuration?[ConfigConstants.StorageType]);

            if (storageType == StorageType.DocumentDB)
            {
                this.ConfigureCosmosDB(services);
            }

            ConfigureStorageAccountServices(services);

            _ = services.AddHttpContextAccessor();

            _ = services.AddAuthentication(ApplicationConstants.BearerAuthenticationScheme).AddJwtBearer(options =>
            {
                options.Authority    = this.Configuration[ConfigConstants.BearerTokenIssuerConfigKey];
                options.ClaimsIssuer = this.Configuration[ConfigConstants.BearerTokenIssuerConfigKey];
                options.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters()
                {
                    ValidateIssuer = false,
                    ValidAudiences = this.Configuration[ConfigConstants.BearerTokenValidAudiencesConfigKey].Split(ApplicationConstants.SplitCharacter),
                };
            });

            ITelemetryInitializer[] itm = new ITelemetryInitializer[1];
            var envInitializer          = new EnvironmentInitializer
            {
                Service         = this.Configuration[AIConstants.ServiceConfigName],
                ServiceLine     = this.Configuration[AIConstants.ServiceLineConfigName],
                ServiceOffering = this.Configuration[AIConstants.ServiceOfferingConfigName],
                ComponentId     = this.Configuration[AIConstants.ComponentIdConfigName],
                ComponentName   = this.Configuration[AIConstants.ComponentNameConfigName],
                EnvironmentName = this.Configuration[AIConstants.EnvironmentName],
                IctoId          = "IctoId",
            };

            itm[0] = envInitializer;

            LoggingConfiguration loggingConfiguration = new LoggingConfiguration
            {
                IsTraceEnabled  = true,
                TraceLevel      = (SeverityLevel)Enum.Parse(typeof(SeverityLevel), this.Configuration[ConfigConstants.AITraceLelelConfigKey]),
                EnvironmentName = this.Configuration[AIConstants.EnvironmentName],
            };

#pragma warning disable CA2000 // Dispose objects before losing scope
            var tconfig = TelemetryConfiguration.CreateDefault();
#pragma warning restore CA2000 // Dispose objects before losing scope
            tconfig.InstrumentationKey = this.Configuration[ConfigConstants.AIInsrumentationConfigKey];

#pragma warning disable CA2000 // Dispose objects before losing scope
            DependencyTrackingTelemetryModule depModule = new DependencyTrackingTelemetryModule();
#pragma warning restore CA2000 // Dispose objects before losing scope
            depModule.Initialize(tconfig);

#pragma warning disable CA2000 // Dispose objects before losing scope
            RequestTrackingTelemetryModule requestTrackingTelemetryModule = new RequestTrackingTelemetryModule();
#pragma warning restore CA2000 // Dispose objects before losing scope
            requestTrackingTelemetryModule.Initialize(tconfig);

            _ = services.AddSingleton <ILogger>(_ => new AILogger(loggingConfiguration, tconfig, itm));
        }
コード例 #8
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to add services to the container.
        /// </summary>
        /// <param name="services">An instance of <see cref="IServiceCollection"/>.</param>
        public void ConfigureServicesCommon(IServiceCollection services)
        {
            _ = services.AddAuthorization(configure =>
            {
                configure.AddPolicy(Constants.AppNameAuthorizePolicy, policy =>
                {
                    policy.Requirements.Add(new AppNameAuthorizeRequirement());
                });
                configure.AddPolicy(Constants.AppAudienceAuthorizePolicy, policy =>
                {
                    policy.Requirements.Add(new AppAudienceAuthorizeRequirement());
                });
            });
            _ = services.AddSingleton <IAuthorizationHandler, AppNameAuthorizePolicyHandler>(s => new AppNameAuthorizePolicyHandler(s.GetService <IHttpContextAccessor>(), this.Configuration));
            _ = services.AddSingleton <IAuthorizationHandler, AppAudienceAuthorizePolicyHandler>(s => new AppAudienceAuthorizePolicyHandler(s.GetService <IHttpContextAccessor>(), this.Configuration));

            _ = services.AddControllers();

            _ = services.AddApplicationInsightsTelemetry();
            _ = services.AddScoped(typeof(ValidateModelAttribute));

            _ = services.AddOptions();
            _ = services.Configure <MSGraphSetting>(this.Configuration.GetSection("MSGraphSetting"));
            _ = services.Configure <MSGraphSetting>(s => s.ClientCredential = this.Configuration["MSGraphSettingClientCredential"]);
            _ = services.Configure <MSGraphSetting>(s => s.ClientId = this.Configuration["MSGraphSettingClientId"]);
            _ = services.Configure <CosmosDBSetting>(this.Configuration.GetSection("CosmosDB"));
            _ = services.Configure <CosmosDBSetting>(s => s.Key = this.Configuration["CosmosDBKey"]);
            _ = services.Configure <CosmosDBSetting>(s => s.Uri = this.Configuration["CosmosDBURI"]);
            _ = services.Configure <StorageAccountSetting>(this.Configuration.GetSection("StorageAccount"));
            _ = services.Configure <StorageAccountSetting>(s => s.ConnectionString = this.Configuration["StorageAccountConnectionString"]);
            _ = services.Configure <UserTokenSetting>(this.Configuration.GetSection("UserTokenSetting"));
            _ = services.Configure <RetrySetting>(this.Configuration.GetSection("RetrySetting"));

            _ = services.AddSingleton <IConfiguration>(this.Configuration);
            _ = services.AddSingleton <IEncryptionService, EncryptionService>();
            _ = services.AddSingleton <IKeyEncryptionKey, CryptographyClient>(cc => new CryptographyClient(new Uri(this.Configuration["KeyVault:RSAKeyUri"]), new DefaultAzureCredential()));

            _ = services.AddTransient <IHttpContextAccessor, HttpContextAccessor>()
                .AddScoped <ICosmosLinqQuery, CustomCosmosLinqQuery>()
                .AddSingleton <ICosmosDBQueryClient, CosmosDBQueryClient>()
                .AddSingleton <ICloudStorageClient, CloudStorageClient>()
                .AddScoped <ITokenHelper, TokenHelper>()
                .AddHttpClient <IMSGraphProvider, MSGraphProvider>();

            _ = services.AddHttpContextAccessor();

            _ = services.AddAuthentication("Bearer").AddJwtBearer(options =>
            {
                options.Authority    = this.Configuration["Authority"];
                options.ClaimsIssuer = this.Configuration["BearerTokenAuthentication:Issuer"];
                options.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters()
                {
                    ValidateIssuer = true,
                    ValidAudiences = this.Configuration["BearerTokenAuthentication:ValidAudiences"].Split(Constants.SplitCharacter),
                };
            });

            ITelemetryInitializer[] itm = new ITelemetryInitializer[1];
            var envInitializer          = new EnvironmentInitializer
            {
                Service         = this.Configuration[Constants.ServiceConfigName],
                ServiceLine     = this.Configuration[Constants.ServiceLineConfigName],
                ServiceOffering = this.Configuration[Constants.ServiceOfferingConfigName],
                ComponentId     = this.Configuration[Constants.ComponentIdConfigName],
                ComponentName   = this.Configuration[Constants.ComponentNameConfigName],
                EnvironmentName = this.Configuration[Constants.EnvironmentName],
                IctoId          = "IctoId",
            };

            itm[0] = envInitializer;

            LoggingConfiguration loggingConfiguration = new LoggingConfiguration
            {
                IsTraceEnabled  = true,
                TraceLevel      = (SeverityLevel)Enum.Parse(typeof(SeverityLevel), this.Configuration["ApplicationInsights:TraceLevel"]),
                EnvironmentName = this.Configuration[Constants.EnvironmentName],
            };

            var tconfig = TelemetryConfiguration.CreateDefault();

            tconfig.InstrumentationKey = this.Configuration["ApplicationInsights:InstrumentationKey"];

            DependencyTrackingTelemetryModule depModule = new DependencyTrackingTelemetryModule();

            depModule.Initialize(tconfig);

            RequestTrackingTelemetryModule requestTrackingTelemetryModule = new RequestTrackingTelemetryModule();

            requestTrackingTelemetryModule.Initialize(tconfig);

            _ = services.AddSingleton <ILogger>(_ => new AILogger(loggingConfiguration, tconfig, itm));
        }
コード例 #9
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to add services to the container.
        /// </summary>
        /// <param name="services">An instance of <see cref="IServiceCollection"/>.</param>
        public void ConfigureServices(IServiceCollection services)
        {
            this.ConfigureServicesCommon(services);

            _ = services.AddMvc();
            _ = services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "NotificationService", Version = "v1"
                });
            });

            ITelemetryInitializer[] itm = new ITelemetryInitializer[1];
            var envInitializer          = new EnvironmentInitializer
            {
                Service         = this.Configuration[Constants.ServiceConfigName],
                ServiceLine     = this.Configuration[Constants.ServiceLineConfigName],
                ServiceOffering = this.Configuration[Constants.ServiceOfferingConfigName],
                ComponentId     = this.Configuration[Constants.ComponentIdConfigName],
                ComponentName   = this.Configuration[Constants.ComponentNameConfigName],
                EnvironmentName = this.Configuration[Constants.EnvironmentName],
                IctoId          = "IctoId",
            };

            itm[0] = envInitializer;

            NotificationProviders.Common.Logger.LoggingConfiguration loggingConfiguration = new NotificationProviders.Common.Logger.LoggingConfiguration
            {
                IsTraceEnabled  = true,
                TraceLevel      = (SeverityLevel)Enum.Parse(typeof(SeverityLevel), this.Configuration["ApplicationInsights:TraceLevel"]),
                EnvironmentName = this.Configuration[Constants.EnvironmentName],
            };

            var tconfig = TelemetryConfiguration.CreateDefault();

            tconfig.InstrumentationKey = this.Configuration["ApplicationInsights:InstrumentationKey"];

            DependencyTrackingTelemetryModule depModule = new DependencyTrackingTelemetryModule();

            depModule.Initialize(tconfig);

            RequestTrackingTelemetryModule requestTrackingTelemetryModule = new RequestTrackingTelemetryModule();

            requestTrackingTelemetryModule.Initialize(tconfig);

            _ = services.AddSingleton <NotificationProviders.Common.Logger.ILogger>(_ => new NotificationProviders.Common.Logger.AILogger(loggingConfiguration, tconfig, itm));


            _ = services.AddSingleton <SendAccountConfiguration>(new SendAccountConfiguration()
            {
                DisplayName = this.Configuration["DirectSendSetting:DisplayName"],
            });

            if (int.TryParse(this.Configuration["DirectSendSetting:SmtpPort"], out int port))
            {
                _ = services.AddSingleton <ISmtpConfiguration>(new SmtpConfiguration()
                {
                    SmtpPort   = port,
                    SmtpServer = this.Configuration["DirectSendSetting:SmtpServer"]
                });
            }

            _ = services.AddSingleton <ISmtpClientFactory, DSSmtpClientFactory>()
                .AddSingleton <ISmtpClientPool, SmtpClientPool>()
                .AddSingleton <IEmailService, DirectSendMailService>();

            _ = services.AddScoped <INotificationReportManager, NotificationReportManager>()
                .AddScoped <IEmailManager, EmailManager>(s =>
                                                         new EmailManager(
                                                             this.Configuration,
                                                             s.GetService <IRepositoryFactory>(),
                                                             s.GetService <ILogger>(),
                                                             s.GetService <IMailTemplateManager>(),
                                                             s.GetService <ITemplateMerge>()))
                .AddScoped <IEmailServiceManager, EmailServiceManager>(s =>
                                                                       new EmailServiceManager(this.Configuration, s.GetService <IRepositoryFactory>(), s.GetService <ICloudStorageClient>(), s.GetService <ILogger>(),
                                                                                               s.GetService <INotificationProviderFactory>(), s.GetService <IEmailManager>()))
                .AddScoped <IRepositoryFactory, RepositoryFactory>()
                .AddScoped <EmailNotificationRepository>()
                .AddScoped <IEmailNotificationRepository, EmailNotificationRepository>(s => s.GetService <EmailNotificationRepository>())
                .AddScoped <TableStorageEmailRepository>()
                .AddScoped <IEmailNotificationRepository, TableStorageEmailRepository>(s => s.GetService <TableStorageEmailRepository>())
                .AddScoped <ITableStorageClient, TableStorageClient>()
                .AddScoped <IMailTemplateManager, MailTemplateManager>()
                .AddScoped <IMailTemplateRepository, MailTemplateRepository>()
                .AddScoped <IMailAttachmentRepository, MailAttachmentRepository>()
                .AddScoped <ITemplateMerge, TemplateMerge>()
                .AddSingleton <IEmailAccountManager, EmailAccountManager>()
                .AddScoped <INotificationProviderFactory, NotificationProviderFactory>()
                .AddScoped <DirectSendNotificationProvider>(s => new DirectSendNotificationProvider(this.Configuration, s.GetService <IEmailService>(), s.GetService <ILogger>(), s.GetService <IEmailManager>()))
                .AddScoped <INotificationProvider, DirectSendNotificationProvider>()
                .AddScoped <MSGraphNotificationProvider>(s => new MSGraphNotificationProvider(this.Configuration, s.GetService <IEmailAccountManager>(), s.GetService <ILogger>(),
                                                                                              Options.Create(this.Configuration.GetSection("MSGraphSetting").Get <MSGraphSetting>()), Options.Create(this.Configuration.GetSection("PollyRetrySetting").Get <RetrySetting>()),
                                                                                              s.GetService <ITokenHelper>(), s.GetService <IMSGraphProvider>(), s.GetService <IEmailManager>()))
                .AddScoped <INotificationProvider, MSGraphNotificationProvider>();
        }
コード例 #10
0
        /// <inheritdoc/>
        public override void Configure(IFunctionsHostBuilder builder)
        {
            var azureFuncConfig = builder?.Services?.BuildServiceProvider()?.GetService <IConfiguration>();
            var configBuilder   = new ConfigurationBuilder();

            _ = configBuilder.AddConfiguration(azureFuncConfig);
            var configFolder = Directory.GetParent(Assembly.GetExecutingAssembly().Location).Parent?.FullName;

            _ = configBuilder.SetBasePath(configFolder);
            _ = configBuilder.AddJsonFile("functionSettings.json");
            _ = configBuilder.AddEnvironmentVariables();

            var configuration = configBuilder.Build();

            MaxDequeueCount = configuration.GetSection(ConfigConstants.MaxDequeueCountConfigKey);

            AzureKeyVaultConfigurationOptions azureKeyVaultConfigurationOptions = new AzureKeyVaultConfigurationOptions(configuration[ConfigConstants.KeyVaultUrlConfigKey])
            {
                ReloadInterval = TimeSpan.FromSeconds(double.Parse(configuration[Constants.KeyVaultConfigRefreshDurationSeconds])),
            };

            _             = configBuilder.AddAzureKeyVault(azureKeyVaultConfigurationOptions);
            configuration = configBuilder.Build();
            _             = configBuilder.AddAzureAppConfiguration(options =>
            {
                var settings = options.Connect(configuration[ConfigConstants.AzureAppConfigConnectionstringConfigKey])
                               .Select(KeyFilter.Any, "Common").Select(KeyFilter.Any, "QueueProcessor");
                _ = settings.ConfigureRefresh(refreshOptions =>
                {
                    _ = refreshOptions.Register(key: configuration[ConfigConstants.ForceRefreshConfigKey], refreshAll: true, label: LabelFilter.Null);
                });
            });

            configuration = configBuilder.Build();

            ITelemetryInitializer[] itm = new ITelemetryInitializer[1];
            var envInitializer          = new EnvironmentInitializer
            {
                Service         = configuration[AIConstants.ServiceConfigName],
                ServiceLine     = configuration[AIConstants.ServiceLineConfigName],
                ServiceOffering = configuration[AIConstants.ServiceOfferingConfigName],
                ComponentId     = configuration[AIConstants.ComponentIdConfigName],
                ComponentName   = configuration[AIConstants.ComponentNameConfigName],
                EnvironmentName = configuration[AIConstants.EnvironmentName],
                IctoId          = "IctoId",
            };

            itm[0] = envInitializer;
            LoggingConfiguration loggingConfiguration = new LoggingConfiguration
            {
                IsTraceEnabled  = true,
                TraceLevel      = (SeverityLevel)Enum.Parse(typeof(SeverityLevel), configuration[ConfigConstants.AITraceLelelConfigKey]),
                EnvironmentName = configuration[AIConstants.EnvironmentName],
            };

            var tconfig = TelemetryConfiguration.CreateDefault();

            tconfig.InstrumentationKey = configuration[ConfigConstants.AIInsrumentationConfigKey];

            DependencyTrackingTelemetryModule depModule = new DependencyTrackingTelemetryModule();

            depModule.Initialize(tconfig);

            RequestTrackingTelemetryModule requestTrackingTelemetryModule = new RequestTrackingTelemetryModule();

            requestTrackingTelemetryModule.Initialize(tconfig);

            _ = builder.Services.AddSingleton <ILogger>(_ => new AILogger(loggingConfiguration, tconfig, itm));

            StorageType storageType = (StorageType)Enum.Parse(typeof(StorageType), configuration?[ConfigConstants.StorageType]);

            if (storageType == StorageType.DocumentDB)
            {
                _ = builder.Services.Configure <CosmosDBSetting>(configuration.GetSection(ConfigConstants.CosmosDBConfigSectionKey));
                _ = builder.Services.Configure <CosmosDBSetting>(s => s.Key = configuration[ConfigConstants.CosmosDBKeyConfigKey]);
                _ = builder.Services.Configure <CosmosDBSetting>(s => s.Uri = configuration[ConfigConstants.CosmosDBURIConfigKey]);
                _ = builder.Services.AddScoped <ICosmosLinqQuery, CustomCosmosLinqQuery>();
                _ = builder.Services.AddSingleton <ICosmosDBQueryClient, CosmosDBQueryClient>();
            }

            _ = builder.Services.Configure <StorageAccountSetting>(configuration.GetSection(ConfigConstants.StorageAccountConfigSectionKey));
            _ = builder.Services.Configure <StorageAccountSetting>(s => s.ConnectionString = configuration[ConfigConstants.StorageAccountConnectionStringConfigKey]);
            _ = builder.Services.AddSingleton <IConfiguration>(configuration);
            _ = builder.Services.AddScoped <IRepositoryFactory, RepositoryFactory>();
            _ = builder.Services.AddScoped <EmailNotificationRepository>();
            _ = builder.Services.AddScoped <IEmailNotificationRepository, EmailNotificationRepository>(s => s.GetService <EmailNotificationRepository>());
            _ = builder.Services.AddScoped <TableStorageEmailRepository>();
            _ = builder.Services.AddScoped <IEmailNotificationRepository, TableStorageEmailRepository>(s => s.GetService <TableStorageEmailRepository>());
            _ = builder.Services.AddScoped <ITableStorageClient, TableStorageClient>();
            _ = builder.Services.AddHttpClient <IHttpClientHelper, HttpClientHelper>();
        }
コード例 #11
0
        /// <inheritdoc/>
        public override void Configure(IFunctionsHostBuilder builder)
        {
            var configuration = builder?.Services?.BuildServiceProvider()?.GetService <IConfiguration>();

            MaxDequeueCount = configuration.GetSection(ConfigConstants.MaxDequeueCountConfigKey);

            _ = builder.Services.AddAzureAppConfiguration();

            ITelemetryInitializer[] itm = new ITelemetryInitializer[1];
            var envInitializer          = new EnvironmentInitializer
            {
                Service         = configuration[AIConstants.ServiceConfigName],
                ServiceLine     = configuration[AIConstants.ServiceLineConfigName],
                ServiceOffering = configuration[AIConstants.ServiceOfferingConfigName],
                ComponentId     = configuration[AIConstants.ComponentIdConfigName],
                ComponentName   = configuration[AIConstants.ComponentNameConfigName],
                EnvironmentName = configuration[AIConstants.EnvironmentName],
                IctoId          = "IctoId",
            };

            itm[0] = envInitializer;
            LoggingConfiguration loggingConfiguration = new LoggingConfiguration
            {
                IsTraceEnabled  = true,
                TraceLevel      = (SeverityLevel)Enum.Parse(typeof(SeverityLevel), configuration[ConfigConstants.AITraceLelelConfigKey]),
                EnvironmentName = configuration[AIConstants.EnvironmentName],
            };

            var tconfig = TelemetryConfiguration.CreateDefault();

            tconfig.InstrumentationKey = configuration[ConfigConstants.AIInsrumentationConfigKey];

            DependencyTrackingTelemetryModule depModule = new DependencyTrackingTelemetryModule();

            depModule.Initialize(tconfig);

            RequestTrackingTelemetryModule requestTrackingTelemetryModule = new RequestTrackingTelemetryModule();

            requestTrackingTelemetryModule.Initialize(tconfig);

            _ = builder.Services.AddSingleton <ILogger>(_ => new AILogger(loggingConfiguration, tconfig, itm));

            StorageType storageType = (StorageType)Enum.Parse(typeof(StorageType), configuration?[ConfigConstants.StorageType]);

            if (storageType == StorageType.DocumentDB)
            {
                _ = builder.Services.Configure <CosmosDBSetting>(configuration.GetSection(ConfigConstants.CosmosDBConfigSectionKey));
                _ = builder.Services.Configure <CosmosDBSetting>(s => s.Key = configuration[ConfigConstants.CosmosDBKeyConfigKey]);
                _ = builder.Services.Configure <CosmosDBSetting>(s => s.Uri = configuration[ConfigConstants.CosmosDBURIConfigKey]);
                _ = builder.Services.AddScoped <ICosmosLinqQuery, CustomCosmosLinqQuery>();
                _ = builder.Services.AddSingleton <ICosmosDBQueryClient, CosmosDBQueryClient>();
                _ = builder.Services.AddScoped <EmailNotificationRepository>();
                _ = builder.Services.AddScoped <IEmailNotificationRepository, EmailNotificationRepository>(s => s.GetService <EmailNotificationRepository>());
            }

            _ = builder.Services.Configure <StorageAccountSetting>(configuration.GetSection(ConfigConstants.StorageAccountConfigSectionKey));
            _ = builder.Services.Configure <StorageAccountSetting>(s => s.ConnectionString = configuration[ConfigConstants.StorageAccountConnectionStringConfigKey]);
            _ = builder.Services.AddScoped <IRepositoryFactory, RepositoryFactory>();
            _ = builder.Services.AddScoped <TableStorageEmailRepository>();
            _ = builder.Services.AddScoped <IEmailNotificationRepository, TableStorageEmailRepository>(s => s.GetService <TableStorageEmailRepository>());
            _ = builder.Services.AddScoped <ITableStorageClient, TableStorageClient>();
            _ = builder.Services.AddHttpClient <IHttpClientHelper, HttpClientHelper>();

            _ = builder.Services.BuildServiceProvider();
        }
コード例 #12
0
 internal override ForwardAnalysisBase createAnalysis(ControlFlowGraph.ControlFlowGraph entryMethodGraph, MemoryModels.MemoryModelFactory memoryModel, EnvironmentInitializer initializer)
 {
     return(new WevercaAnalysisTest(entryMethodGraph, memoryModel, initializer));
 }
コード例 #13
0
 /// <summary>
 /// Creates an instance of ForwardAnalysis corresponding to given enumeration item.
 /// </summary>
 /// <returns>an instance of ForwardAnalysis corresponding to given enumeration item</returns>
 internal abstract ForwardAnalysisBase createAnalysis(ControlFlowGraph.ControlFlowGraph entryMethodGraph, MemoryModels.MemoryModelFactory memoryModel, EnvironmentInitializer initializer);
コード例 #14
0
 public WevercaFunctionResolverTest(EnvironmentInitializer envinronmentInitializer)
 {
     _environmentInitializer = envinronmentInitializer;
 }
コード例 #15
0
 public WevercaAnalysisTest(ControlFlowGraph.ControlFlowGraph entryMethodGraph, MemoryModels.MemoryModelFactory memoryModel, EnvironmentInitializer initializer)
     : base(entryMethodGraph, memoryModel)
 {
     _flowResolver     = new WevercaFlowResolverTest();
     _functionResolver = new WevercaFunctionResolverTest(initializer);
 }