Пример #1
0
        public ShellViewModel(IMenuService menuService
            , IAppConfiguration appConfiguration
            , IUserSettingsService settings)
            : base()
        {
            this.PageLoadingCommand = DelegateCommand.FromAsyncHandler(PageLoading);
            this.UserSettingsService = settings;
            this.AppName = appConfiguration.AppName;
            this.WriteReadyStatus();

            this.ToggleFullScreenCommand = new DelegateCommand<object>(o =>
            {
                if (o is IToggleFullScreen)
                {
                    var tfs = o as IToggleFullScreen;
                    tfs.ToggleFullScreen = !tfs.ToggleFullScreen;
                }
                this.ToggleFullScreen = !this.ToggleFullScreen;
            });

            Menu = menuService.Menu.ToObservableCollection();
            EventAggregator.GetEvent<MenuUpdated>().Subscribe(m =>
            {
                Menu.Clear();
                Menu.AddRange(m.ToObservableCollection());
            });
            EventAggregator.GetEvent<SubMenuVisibilityChanged>().Subscribe(m => this.IsSubMenuVisible = m);
        }
Пример #2
0
 public MessageService(IMailSender mailSender, IAppConfiguration config, AuthenticationService authService)
     : this()
 {
     MailSender = mailSender;
     Config = config;
     AuthService = authService;
 }
 public PackagesController(
     IPackageService packageService,
     IUploadFileService uploadFileService,
     IMessageService messageService,
     ISearchService searchService,
     IAutomaticallyCuratePackageCommand autoCuratedPackageCmd,
     IPackageFileService packageFileService,
     IEntitiesContext entitiesContext,
     IAppConfiguration config,
     IIndexingService indexingService,
     ICacheService cacheService,
     EditPackageService editPackageService,
     IPackageDeleteService packageDeleteService,
     ISupportRequestService supportRequestService,
     AuditingService auditingService)
 {
     _packageService = packageService;
     _uploadFileService = uploadFileService;
     _messageService = messageService;
     _searchService = searchService;
     _autoCuratedPackageCmd = autoCuratedPackageCmd;
     _packageFileService = packageFileService;
     _entitiesContext = entitiesContext;
     _config = config;
     _indexingService = indexingService;
     _cacheService = cacheService;
     _editPackageService = editPackageService;
     _packageDeleteService = packageDeleteService;
     _supportRequestService = supportRequestService;
     _auditingService = auditingService;
 }
Пример #4
0
 public UserService(
     IAppConfiguration config,
     IEntityRepository<User> userRepository) : this()
 {
     Config = config;
     UserRepository = userRepository;
 }
Пример #5
0
        private static void InitializeDynamicData(RouteCollection routes, string root, IAppConfiguration configuration)
        {
            try
            {
                DefaultModel.RegisterContext(
                    new EFCodeFirstDataModelProvider(
                        () => new EntitiesContext(configuration.SqlConnectionString, readOnly: false)), // DB Admins do not need to respect read-only mode.
                        configuration: new ContextConfiguration { ScaffoldAllTables = true });
            }
            catch (SqlException e)
            {
                QuietLog.LogHandledException(e);
                return;
            }
            catch (DataException e)
            {
                QuietLog.LogHandledException(e);
                return;
            }

            // This route must come first to prevent some other route from the site to take over
            _route = new DynamicDataRoute(root + "/{table}/{action}")
            {
                Constraints = new RouteValueDictionary(new { action = "List|Details|Edit|Insert" }),
                Model = DefaultModel
            };
            routes.Insert(0, _route);

            routes.MapPageRoute(
                "dd_default",
                root,
                "~/Areas/Admin/DynamicData/Default.aspx");
        }
Пример #6
0
        public ExternalSearchService(IAppConfiguration config, IDiagnosticsService diagnostics)
        {
            ServiceUri = config.ServiceDiscoveryUri;

            Trace = diagnostics.SafeGetSource("ExternalSearchService");

            // Extract credentials
            var userInfo = ServiceUri.UserInfo;
            ICredentials credentials = null;
            if (!String.IsNullOrEmpty(userInfo))
            {
                var split = userInfo.Split(':');
                if (split.Length != 2)
                {
                    throw new FormatException("Invalid user info in SearchServiceUri!");
                }

                // Split the credentials out
                credentials = new NetworkCredential(split[0], split[1]);
                ServiceUri = new UriBuilder(ServiceUri)
                {
                    UserName = null,
                    Password = null
                }.Uri;
            }

            if (_healthIndicatorStore == null)
            {
                _healthIndicatorStore = new BaseUrlHealthIndicatorStore(new AppInsightsHealthIndicatorLogger());
            }

            _client = new SearchClient(ServiceUri, config.SearchServiceResourceType, credentials, _healthIndicatorStore, new TracingHttpHandler(Trace));
        }
Пример #7
0
 public HomeController(
     Func<IWeeeClient> apiClient,
     IAppConfiguration configuration)
 {
     this.configuration = configuration;
     this.apiClient = apiClient;
 }
        internal string FillIn(string subject, IAppConfiguration config)
        {
            // note, format blocks {xxx} are matched by ordinal-case-sensitive comparison
            var builder = new StringBuilder(subject);

            Substitute(builder, "{GalleryOwnerName}", config.GalleryOwner.DisplayName);
            Substitute(builder, "{Id}", Package.PackageRegistration.Id);
            Substitute(builder, "{Version}", Package.Version);
            Substitute(builder, "{Reason}", Reason);
            if (RequestingUser != null)
            {
                Substitute(builder, "{User}", String.Format(
                    CultureInfo.CurrentCulture,
                    "{2}**User:** {0} ({1}){2}{3}",
                    RequestingUser.Username,
                    RequestingUser.EmailAddress,
                    Environment.NewLine,
                    Url.User(RequestingUser, scheme: "http")));
            }
            else
            {
                Substitute(builder, "{User}", "");
            }
            Substitute(builder, "{Name}", FromAddress.DisplayName);
            Substitute(builder, "{Address}", FromAddress.Address);
            Substitute(builder, "{AlreadyContactedOwners}", AlreadyContactedOwners ? "Yes" : "No");
            Substitute(builder, "{PackageUrl}", Url.Package(Package.PackageRegistration.Id, null, scheme: "http"));
            Substitute(builder, "{VersionUrl}", Url.Package(Package.PackageRegistration.Id, Package.Version, scheme: "http"));
            Substitute(builder, "{Reason}", Reason);
            Substitute(builder, "{Signature}", Signature);
            Substitute(builder, "{Message}", Message);

            builder.Replace(@"\{\", "{");
            return builder.ToString();
        }
 public PackagesController(
     IPackageService packageService,
     IUploadFileService uploadFileService,
     IUserService userService,
     IMessageService messageService,
     ISearchService searchService,
     IAutomaticallyCuratePackageCommand autoCuratedPackageCmd,
     INuGetExeDownloaderService nugetExeDownloaderService,
     IPackageFileService packageFileService,
     IEntitiesContext entitiesContext,
     IAppConfiguration config,
     IIndexingService indexingService,
     ICacheService cacheService)
 {
     _packageService = packageService;
     _uploadFileService = uploadFileService;
     _userService = userService;
     _messageService = messageService;
     _searchService = searchService;
     _autoCuratedPackageCmd = autoCuratedPackageCmd;
     _nugetExeDownloaderService = nugetExeDownloaderService;
     _packageFileService = packageFileService;
     _entitiesContext = entitiesContext;
     _config = config;
     _indexingService = indexingService;
     _cacheService = cacheService;
 }
 public ApiController(
     IEntitiesContext entitiesContext,
     IPackageService packageService,
     IPackageFileService packageFileService,
     IUserService userService,
     INuGetExeDownloaderService nugetExeDownloaderService,
     IContentService contentService,
     IIndexingService indexingService,
     ISearchService searchService,
     IAutomaticallyCuratePackageCommand autoCuratePackage,
     IStatusService statusService,
     IAppConfiguration config)
 {
     EntitiesContext = entitiesContext;
     PackageService = packageService;
     PackageFileService = packageFileService;
     UserService = userService;
     NugetExeDownloaderService = nugetExeDownloaderService;
     ContentService = contentService;
     StatisticsService = null;
     IndexingService = indexingService;
     SearchService = searchService;
     AutoCuratePackage = autoCuratePackage;
     StatusService = statusService;
     _config = config;
 }
Пример #11
0
        public static void Register(RouteCollection routes, string root, IAppConfiguration configuration)
        {
            // Set up unobtrusive validation
            InitializeValidation();

            // Set up dynamic data
            InitializeDynamicData(routes, root, configuration);
        }
        public SupportRequestService(
            ISupportRequestDbContext supportRequestDbContext,
            IAppConfiguration config)
        {
            _supportRequestDbContext = supportRequestDbContext;
            _siteRoot = config.SiteRoot;

            _pagerDutyClient = new PagerDutyClient(config.PagerDutyAccountName, config.PagerDutyAPIKey, config.PagerDutyServiceKey);
        }
Пример #13
0
 public AzureManagement(IMlogger logger, IAppConfiguration configuration, IDataExporter dataExporter)
 {
     Logger = logger;
     Configuration = configuration;
     var subscriptionId = configuration.SubscriptionId();
     var base64EncodedCertificate = configuration.Base64EncodedManagementCertificate();
     MyCloudCredentials = getCredentials(subscriptionId, base64EncodedCertificate);
     Exporter = dataExporter;
 }
Пример #14
0
 public StatusService(
     IEntitiesContext entities,
     IFileStorageService fileStorageService,
     IAppConfiguration config)
 {
     _entities = entities;
     _fileStorageService = fileStorageService;
     _config = config;
 }
 public ChargeController(
     IAppConfiguration configuration,
     BreadcrumbService breadcrumb,
     Func<IWeeeClient> weeeClient)
 {
     this.configuration = configuration;
     this.breadcrumb = breadcrumb;
     this.weeeClient = weeeClient;
 }
Пример #16
0
        public AuthenticationService(
            IEntitiesContext entities, IAppConfiguration config, IDiagnosticsService diagnostics,
            AuditingService auditing, IEnumerable<Authenticator> providers, ICredentialBuilder credentialBuilder,
            ICredentialValidator credentialValidator, IDateTimeProvider dateTimeProvider)
        {
            if (entities == null)
            {
                throw new ArgumentNullException(nameof(entities));
            }

            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            if (diagnostics == null)
            {
                throw new ArgumentNullException(nameof(diagnostics));
            }

            if (auditing == null)
            {
                throw new ArgumentNullException(nameof(auditing));
            }

            if (providers == null)
            {
                throw new ArgumentNullException(nameof(providers));
            }

            if (credentialBuilder == null)
            {
                throw new ArgumentNullException(nameof(credentialBuilder));
            }

            if (credentialValidator == null)
            {
                throw new ArgumentNullException(nameof(credentialValidator));
            }

            if (dateTimeProvider == null)
            {
                throw new ArgumentNullException(nameof(dateTimeProvider));
            }

            InitCredentialFormatters();

            Entities = entities;
            _config = config;
            Auditing = auditing;
            _trace = diagnostics.SafeGetSource("AuthenticationService");
            Authenticators = providers.ToDictionary(p => p.Name, StringComparer.OrdinalIgnoreCase);
            _credentialBuilder = credentialBuilder;
            _credentialValidator = credentialValidator;
            _dateTimeProvider = dateTimeProvider;
        }
Пример #17
0
 public UsersController(
     IUserService userService,
     IMessageService messageService,
     IAppConfiguration config,
     AuthenticationService authService)
 {
     UserService = userService;
     MessageService = messageService;
     Config = config;
     AuthService = authService;
 }
Пример #18
0
 public UserService(
     IAppConfiguration config,
     IEntityRepository<User> userRepository,
     IEntityRepository<Credential> credentialRepository,
     AuditingService auditing)
     : this()
 {
     Config = config;
     UserRepository = userRepository;
     CredentialRepository = credentialRepository;
     Auditing = auditing;
 }
        public UsersController(
            ICuratedFeedService feedsQuery,
            IUserService userService,
            IPackageService packageService,
            IMessageService messageService,
            IAppConfiguration config,
            AuthenticationService authService,
            ICredentialBuilder credentialBuilder)
        {
            if (feedsQuery == null)
            {
                throw new ArgumentNullException(nameof(feedsQuery));
            }

            if (userService == null)
            {
                throw new ArgumentNullException(nameof(userService));
            }

            if (packageService == null)
            {
                throw new ArgumentNullException(nameof(packageService));
            }

            if (messageService == null)
            {
                throw new ArgumentNullException(nameof(messageService));
            }

            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            if (authService == null)
            {
                throw new ArgumentNullException(nameof(authService));
            }

            if (credentialBuilder == null)
            {
                throw new ArgumentNullException(nameof(credentialBuilder));
            }

            _curatedFeedService = feedsQuery;
            _userService = userService;
            _packageService = packageService;
            _messageService = messageService;
            _config = config;
            _authService = authService;
            _credentialBuilder = credentialBuilder;
        }
Пример #20
0
 public UsersController(
     ICuratedFeedService feedsQuery,
     IUserService userService,
     IPackageService packageService,
     IMessageService messageService,
     IAppConfiguration config) : this()
 {
     CuratedFeedService = feedsQuery;
     UserService = userService;
     PackageService = packageService;
     MessageService = messageService;
     Config = config;
 }
        public LuceneIndexingService(
            IEntityRepository<Package> packageSource,
            IEntityRepository<CuratedPackage> curatedPackageSource,
            Lucene.Net.Store.Directory directory,
			IDiagnosticsService diagnostics,
            IAppConfiguration config)
        {
            _packageRepository = packageSource;
            _curatedPackageRepository = curatedPackageSource;
            _directory = directory;
            _getShouldAutoUpdate = config == null ? new Func<bool>(() => true) : new Func<bool>(() => config.AutoUpdateSearchIndex);
            Trace = diagnostics.SafeGetSource("LuceneIndexingService");
        }
Пример #22
0
 public ProjectsController(
     IProjectService projectService,
     IMessageService messageService,
     IEntitiesContext entitiesContext,
     IAppConfiguration config,
     ICacheService cacheService) 
 {
     _projectService = projectService;
     _messageService = messageService;
     _entitiesContext = entitiesContext;
     _config = config;
     _cacheService = cacheService;
 }
        public AuthenticationService(IEntitiesContext entities, IAppConfiguration config, IDiagnosticsService diagnostics, AuditingService auditing, IEnumerable<Authenticator> providers)
        {
            _credentialFormatters = new Dictionary<string, Func<string, string>>(StringComparer.OrdinalIgnoreCase) {
                { "password", _ => Strings.CredentialType_Password },
                { "apikey", _ => Strings.CredentialType_ApiKey },
                { "external", FormatExternalCredentialType }
            };

            Entities = entities;
            Config = config;
            Auditing = auditing;
            Trace = diagnostics.SafeGetSource("AuthenticationService");
            Authenticators = providers.ToDictionary(p => p.Name, StringComparer.OrdinalIgnoreCase);
        }
Пример #24
0
 public UsersController(
     ICuratedFeedService feedsQuery,
     IUserService userService,
     IPackageService packageService,
     IMessageService messageService,
     IAppConfiguration config,
     AuthenticationService authService)
 {
     CuratedFeedService = feedsQuery;
     UserService = userService;
     PackageService = packageService;
     MessageService = messageService;
     Config = config;
     AuthService = authService;
 }
Пример #25
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app, IAppConfiguration config)
        {
            ReturnUrlMapping returnUrlMapping = new ReturnUrlMapping();
            returnUrlMapping.Add("/account/sign-out", null);
            returnUrlMapping.Add("/admin/account/sign-out", null);

            app.UseCookieAuthentication(new CookieAuthenticationOptions()
            {
                AuthenticationType = Constants.WeeeAuthType,
                LoginPath = new PathString("/account/sign-in"),
                SlidingExpiration = true,
                ExpireTimeSpan = TimeSpan.FromMinutes(60),
                CookieName = EA.Prsd.Core.Web.Constants.CookiePrefix + Constants.WeeeAuthType,
                Provider = new WeeeCookieAuthenticationProvider(returnUrlMapping)
            });
        }
Пример #26
0
 public ApiController(
     IEntitiesContext entitiesContext,
     IPackageService packageService,
     IPackageFileService packageFileService,
     IUserService userService,
     INuGetExeDownloaderService nugetExeDownloaderService,
     IContentService contentService,
     IIndexingService indexingService,
     ISearchService searchService,
     IAutomaticallyCuratePackageCommand autoCuratePackage,
     IStatusService statusService,
     IStatisticsService statisticsService,
     IAppConfiguration config)
     : this(entitiesContext, packageService, packageFileService, userService, nugetExeDownloaderService, contentService, indexingService, searchService, autoCuratePackage, statusService, config)
 {
     StatisticsService = statisticsService;
 }
Пример #27
0
        internal string FillIn(string subject, IAppConfiguration config)
        {
            // note, format blocks {xxx} are matched by ordinal-case-sensitive comparison
            var ret = new StringBuilder(subject);
            Action<string, string> substitute = (target, value) => ret.Replace(target, Escape(value));

            substitute("{GalleryOwnerName}", config.GalleryOwner.DisplayName);
            substitute("{Id}", Package.PackageRegistration.Id);
            substitute("{Version}", Package.Version);
            substitute("{Reason}", Reason);
            if (RequestingUser != null)
            {
                substitute("{Username}", RequestingUser.Username);
                substitute("{UserUrl}", Url.User(RequestingUser, scheme: "http"));
                if (RequestingUser.EmailAddress != null)
                {
                    substitute("{UserAddress}", RequestingUser.EmailAddress);
                }
            }
            substitute("{Name}", FromAddress.DisplayName);
            substitute("{Address}", FromAddress.Address);
            substitute("{AlreadyContactedOwners}", AlreadyContactedOwners ? "Yes" : "No");
            substitute("{PackageUrl}", Url.Package(Package.PackageRegistration.Id, null, scheme: "http"));
            substitute("{VersionUrl}", Url.Package(Package.PackageRegistration.Id, Package.Version, scheme: "http"));
            substitute("{Reason}", Reason);
            substitute("{Message}", Message);

            var ownersText = new StringBuilder("");
            foreach (var owner in Package.PackageRegistration.Owners)
            {
                ownersText.AppendFormat(
                    CultureInfo.InvariantCulture,
                    "{0} - {1} - ({2})",
                    owner.Username,
                    Url.User(owner, scheme: "http"),
                    owner.EmailAddress);
                ownersText.AppendLine();
            }

            substitute("{OwnerList}", ownersText.ToString());

            ret.Replace(@"\{\", "{");
            return ret.ToString();
        }
Пример #28
0
        protected override void OnInit(EventArgs e)
        {
            // Cheap and easy DI. Not too clean :)
            Config = NuGetGallery.Container.Kernel.Get<IAppConfiguration>();

            if (!Page.User.Identity.IsAuthenticated)
            {
                Response.StatusCode = (int)HttpStatusCode.Unauthorized;
                Response.End();
            }

            if (!Request.IsLocal && !Page.User.IsAdministrator())
            {
                Response.StatusCode = (int)HttpStatusCode.Forbidden;
                Response.End();
            }

            base.OnInit(e);
        }
Пример #29
0
        private static void AppPostStart(IAppConfiguration configuration)
        {
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            NuGetODataConfig.Register(GlobalConfiguration.Configuration);

            // Attach correlator
            var correlationHandler = new Correlator.Handlers.ClientCorrelationHandler
            {
                InitializeIfEmpty = true,
                TraceCorrelation  = true
            };

            GlobalConfiguration.Configuration.MessageHandlers.Add(correlationHandler);

            Routes.RegisterRoutes(RouteTable.Routes, configuration.FeedOnlyMode);
            AreaRegistration.RegisterAllAreas();

            GlobalFilters.Filters.Add(new SendErrorsToTelemetryAttribute {
                View = "~/Views/Errors/InternalError.cshtml"
            });
            GlobalFilters.Filters.Add(new ReadOnlyModeErrorFilter());
            GlobalFilters.Filters.Add(new AntiForgeryErrorFilter());
            ValueProviderFactories.Factories.Add(new HttpHeaderValueProviderFactory());
        }
Пример #30
0
        private ExportViewModel(Authentication authentication, IDataBase dataBase, string[] selectedPaths)
            : base(Resources.Title_Export)
        {
            this.authentication = authentication;
            this.dataBase       = dataBase;
            this.dataBase.Dispatcher.VerifyAccess();
            this.exportService = dataBase.GetService(typeof(IExportService)) as IExportService;
            this.configService = dataBase.GetService(typeof(IAppConfiguration)) as IAppConfiguration;

            this.root = new TableRootTreeViewItemViewModel(authentication, this.dataBase, this)
            {
                IsExpanded = true,
            };
            this.categories = new ObservableCollection <ExportTreeViewItemViewModel>
            {
                this.root
            };
            this.SelectItems(this.root, selectedPaths);

            this.exporters        = new ObservableCollection <IExporter>(this.exportService.Exporters);
            this.SelectedExporter = this.exporters.FirstOrDefault(item => item.Name == (string)this.configService[this.GetType(), nameof(SelectedExporter)]);

            this.configService?.Update(this);
        }
Пример #31
0
 public SqlAggregateStatsService(IAppConfiguration configuration)
 {
     this.configuration = configuration;
 }
Пример #32
0
 public WkHtmlToImage(IAppConfiguration appConfiguration)
 {
     _appConfiguration = appConfiguration;
 }
Пример #33
0
 public ConfigController(IAppConfiguration config)
 {
     _config = config;
 }
Пример #34
0
 public RecorderApi(IAppConfiguration appConfiguration)
 {
     client = new HttpClient();
     this.appConfiguration = appConfiguration;
 }
Пример #35
0
 public HomeController(IIdentityServerInteractionService interaction, IAppConfiguration appConfiguration, IClientManagementStore clientStore)
 {
     _interaction           = interaction;
     _appConfiguration      = appConfiguration;
     _clientManagementStore = clientStore;
 }
Пример #36
0
 public UserProfileRepository(IAppConfiguration config, IUserRoleMapper userRoleMapper)
 {
     _config         = config;
     _userRoleMapper = userRoleMapper;
 }
 public TestBootstrapper(IAppConfiguration appConfig, ILogger logger, ClaimsPrincipal claimsPrincipal)
     : base(appConfig, logger)
 {
     _claimsPrincipal = claimsPrincipal;
 }
Пример #38
0
 /// <summary>
 /// </summary>
 /// <param name="configuration"></param>
 /// <param name="descriptors"></param>
 /// <returns></returns>
 public static IIocAppConfiguration UseCastleWindsorForAspNetCore(this IAppConfiguration configuration,
                                                                  IEnumerable <ServiceDescriptor> descriptors)
 {
     return(configuration.UseCastleWindsor(false).Register(descriptors));
 }
Пример #39
0
 /// <summary>
 /// </summary>
 /// <param name="configuration"></param>
 /// <returns></returns>
 public static IIocAppConfiguration UseCastleWindsorForAspNet(this IAppConfiguration configuration)
 {
     return(configuration.UseCastleWindsor(true));
 }
Пример #40
0
 public BaseLogRepository(ILog log, IAppConfiguration config)
 {
     this.log    = log;
     this.config = config;
 }
Пример #41
0
 /// <summary>
 /// </summary>
 /// <param name="configuration"></param>
 /// <returns></returns>
 public static IIocAppConfiguration UseCastleWindsor(this IAppConfiguration configuration)
 {
     return(configuration.UseCastleWindsor(false));
 }
Пример #42
0
 public MessageService(IMailSender mailSender, IAppConfiguration config)
     : base(mailSender, config)
 {
 }
Пример #43
0
 public NewsController(IAppConfiguration configurations)
     : base("NewsController.", configurations)
 {
 }
Пример #44
0
        public virtual IServiceProvider RegisterDependencies(IServiceCollection services, IConfigurationRoot configuration, IAppConfiguration config)
        {
            var containerBuilder = new ContainerBuilder();

            //register engine
            containerBuilder.RegisterInstance(this).As <IEngine>().SingleInstance();

            //register assembly finder
            var assemblyHelper = new AssemblyHelper();

            containerBuilder.RegisterInstance(assemblyHelper).As <IAssemblyHelper>().SingleInstance();

            //find dependency registrars provided by other assemblies
            var dependencyRegistrars = assemblyHelper.FindOfType <IDependencyRegistrar>();

            //create and sort instances of dependency registrars
            var instances = dependencyRegistrars
                            .Select(dependencyRegistrar => (IDependencyRegistrar)Activator.CreateInstance(dependencyRegistrar))
                            .OrderBy(dependencyRegistrar => dependencyRegistrar.Priority);

            var dependencyConfig = new DependencyContext
            {
                ContainerBuilder  = containerBuilder,
                AssemblyHelper    = assemblyHelper,
                ConfigurationRoot = configuration,
                AppConfig         = config
            };

            //register all provided dependencies
            foreach (var dependencyRegistrar in instances)
            {
                dependencyRegistrar.Register(dependencyConfig);
            }

            //populate Autofac container builder with the set of registered service descriptors
            containerBuilder.Populate(services);

            //create service provider
            _serviceProvider = new AutofacServiceProvider(containerBuilder.Build());

            var startupTasks  = assemblyHelper.FindOfType <IStartupTask>();
            var taskInstances = startupTasks
                                .Select(task => (IStartupTask)Activator.CreateInstance(task))
                                .OrderBy(task => task.Priority);

            foreach (var task in taskInstances)
            {
                task.Execute();
            }

            return(_serviceProvider);
        }
Пример #45
0
 public DemoBootstrapper(IAppConfiguration appConfig)
 {
     this.appConfig = appConfig;
 }
Пример #46
0
        public OverlayService(IStatisticProvider statisticProvider,
                              ISensorService sensorService,
                              IOverlayEntryProvider overlayEntryProvider,
                              IAppConfiguration appConfiguration,
                              ILogger <OverlayService> logger,
                              IRecordManager recordManager,
                              IRTSSService rTSSService)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            _statisticProvider    = statisticProvider;
            _overlayEntryProvider = overlayEntryProvider;
            _appConfiguration     = appConfiguration;
            _logger                 = logger;
            _recordManager          = recordManager;
            _rTSSService            = rTSSService;
            _numberOfRuns           = _appConfiguration.SelectedHistoryRuns;
            SecondMetric            = _appConfiguration.SecondMetricOverlay;
            ThirdMetric             = _appConfiguration.ThirdMetricOverlay;
            IsOverlayActiveStream   = new BehaviorSubject <bool>(_appConfiguration.IsOverlayActive);
            _runHistoryOutlierFlags = Enumerable.Repeat(false, _numberOfRuns).ToArray();

            _logger.LogDebug("{componentName} Ready", this.GetType().Name);

            IsOverlayActiveStream.AsObservable()
            .Select(isActive =>
            {
                if (isActive)
                {
                    TryCloseRTSS();
                    _rTSSService.CheckRTSSRunning().Wait();
                    _rTSSService.ResetOSD();
                    return(sensorService.OnDictionaryUpdated
                           .SelectMany(_ => _overlayEntryProvider.GetOverlayEntries()));
                }
                else
                {
                    // OSD status logging
                    Task.Run(async() =>
                    {
                        var processId = await _rTSSService.ProcessIdStream.Take(1);
                        try
                        {
                            _logger.LogInformation("Is process {detectedProcess} detected: {isDetected}", processId, _rTSSService.IsProcessDetected(processId));
                        }
                        catch
                        {
                            _logger.LogError("Error while checking RTSS core process detection");
                        }

                        //try
                        //{
                        //    _logger.LogInformation("Is OS locked: {isLocked}", _rTSSService.IsOSDLocked());
                        //}
                        //catch
                        //{
                        //    _logger.LogError("Error while checking RTSS core OSD lock status");
                        //}
                    }).Wait();

                    _rTSSService.ReleaseOSD();
                    return(Observable.Empty <IOverlayEntry[]>());
                }
            }).Switch()
            .SubscribeOn(Scheduler.Default)
            .Subscribe(async entries =>
            {
                _rTSSService.SetOverlayEntries(entries);
                await _rTSSService.CheckRTSSRunningAndRefresh();
            });

            _runHistory = Enumerable.Repeat("N/A", _numberOfRuns).ToList();
            _rTSSService.SetRunHistory(_runHistory.ToArray());
            _rTSSService.SetRunHistoryAggregation(string.Empty);
            _rTSSService.SetRunHistoryOutlierFlags(_runHistoryOutlierFlags);
            _rTSSService.SetIsCaptureTimerActive(false);

            stopwatch.Stop();
            _logger.LogInformation(GetType().Name + " {initializationTime}s initialization time", Math.Round(stopwatch.ElapsedMilliseconds * 1E-03, 1));
        }
Пример #47
0
        public FilterConfigTests()
        {
            configuration = A.Fake <IAppConfiguration>();

            config = new FilterConfig(configuration);
        }
Пример #48
0
 public Bootstrapper(IAppConfiguration config, IServiceCollection services)
 {
     this.services = services;
     this.config   = config;
 }
Пример #49
0
 public SendEmailHandler(IAppConfiguration appConfiguration)
 {
     _appConfiguration = appConfiguration.GetAppConfiguration();
 }
Пример #50
0
 public LogTypeRepository(ILog log, IAppConfiguration config, IAppDBManager dbManager)
 {
     this.log       = log;
     this.config    = config;
     this.dbManager = dbManager;
 }
 public SqlServerConfigurator(IAppConfiguration appConfiguration) : base(appConfiguration)
 {
 }
Пример #52
0
        public OverlayService(IStatisticProvider statisticProvider,
                              ISensorService sensorService,
                              IOverlayEntryProvider overlayEntryProvider,
                              IAppConfiguration appConfiguration,
                              ILogger <OverlayService> logger,
                              IRecordManager recordManager,
                              IRTSSService rTSSService,
                              IOverlayEntryCore overlayEntryCore)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            _statisticProvider    = statisticProvider;
            _overlayEntryProvider = overlayEntryProvider;
            _appConfiguration     = appConfiguration;
            _logger           = logger;
            _recordManager    = recordManager;
            _sensorService    = sensorService;
            _rTSSService      = rTSSService;
            _overlayEntryCore = overlayEntryCore;

            _numberOfRuns           = _appConfiguration.SelectedHistoryRuns;
            SecondMetric            = _appConfiguration.RunHistorySecondMetric;
            ThirdMetric             = _appConfiguration.RunHistoryThirdMetric;
            IsOverlayActiveStream   = new BehaviorSubject <bool>(_appConfiguration.IsOverlayActive);
            _runHistoryOutlierFlags = Enumerable.Repeat(false, _numberOfRuns).ToArray();

            _logger.LogDebug("{componentName} Ready", this.GetType().Name);

            Task.Run(async() => await InitializeOverlayEntryDict())
            .ContinueWith(t =>
            {
                IsOverlayActiveStream
                .AsObservable()
                .Select(isActive =>
                {
                    if (isActive)
                    {
                        _rTSSService.CheckRTSSRunning().Wait();
                        _rTSSService.OnOSDOn();
                        _rTSSService.ClearOSD();
                        return(_onDictionaryUpdated.
                               SelectMany(_ => _overlayEntryProvider.GetOverlayEntries()));
                    }
                    else
                    {
                        _rTSSService.ReleaseOSD();
                        return(Observable.Empty <IOverlayEntry[]>());
                    }
                })
                .Switch()
                .Subscribe(async entries =>
                {
                    _rTSSService.SetOverlayEntries(entries);
                    await _rTSSService.CheckRTSSRunningAndRefresh();
                });
            });



            _sensorService.SensorSnapshotStream
            .Sample(_sensorService.OsdUpdateStream.Select(timespan => Observable.Concat(Observable.Return(-1L), Observable.Interval(timespan))).Switch())
            .Where((_, idx) => idx == 0 || IsOverlayActive)
            .SubscribeOn(Scheduler.Default)
            .Subscribe(sensorData =>
            {
                UpdateOverlayEntries(sensorData.Item2);
                _onDictionaryUpdated.OnNext(_overlayEntryCore.OverlayEntryDict.Values.ToArray());
            });

            _runHistory = Enumerable.Repeat("N/A", _numberOfRuns).ToList();
            _rTSSService.SetRunHistory(_runHistory.ToArray());
            _rTSSService.SetRunHistoryAggregation(string.Empty);
            _rTSSService.SetRunHistoryOutlierFlags(_runHistoryOutlierFlags);
            _rTSSService.SetIsCaptureTimerActive(false);

            stopwatch.Stop();
            _logger.LogInformation(GetType().Name + " {initializationTime}s initialization time", Math.Round(stopwatch.ElapsedMilliseconds * 1E-03, 1));
        }
Пример #53
0
 public AppSettingsSectionViewModel(IAppConfiguration appConfiguration)
 {
     _appConfiguration = appConfiguration;
 }
 public IngredientsRepository(IAppConfiguration configuration)
 {
     _tableStorage     = new TableStorage(configuration);
     _ingredientsTable = configuration.GetVariable("IngredientsTable");
 }
Пример #55
0
 public TheCatWebAPIService(IAppConfiguration appConfiguration)
 {
     this.appSettings = appConfiguration.GetAppSettings();
 }
 public FormsAuthenticationService(IAppConfiguration configuration)
 {
     _configuration = configuration;
 }
 public static void Initialize(IAppConfiguration c)
 {
     _config = c;
 }
Пример #58
0
 /// <summary>
 /// 构造方法
 /// </summary>
 /// <param name="symmetricalEncryption">加密</param>
 /// <param name="appConfig">应用配置</param>
 public RabbitConnectionFactory(ISymmetricalEncryption symmetricalEncryption = null, IAppConfiguration appConfig = null)
     : base(symmetricalEncryption, appConfig)
 {
 }
Пример #59
0
        private static void BackgroundJobsPostStart(IAppConfiguration configuration)
        {
            var indexer = Container.Kernel.TryGet<IIndexingService>();
            var jobs = new List<IJob>();
            if (indexer != null)
            {
                indexer.RegisterBackgroundJobs(jobs, configuration);
            }
            if (!configuration.HasWorker)
            {
                jobs.Add(
                    new UpdateStatisticsJob(TimeSpan.FromMinutes(5), 
                        () => new EntitiesContext(configuration.SqlConnectionString, readOnly: false), 
                        timeout: TimeSpan.FromMinutes(5)));
            }
            if (configuration.CollectPerfLogs)
            {
                jobs.Add(CreateLogFlushJob());
            }

            if (jobs.AnySafe())
            {
                var jobCoordinator = new NuGetJobCoordinator();
                _jobManager = new JobManager(jobs, jobCoordinator)
                    {
                        RestartSchedulerOnFailure = true
                    };
                _jobManager.Fail(e => ErrorLog.GetDefault(null).Log(new Error(e)));
                _jobManager.Start();
            }
        }
Пример #60
0
 private ProcessList(string filename, IAppConfiguration appConfiguration)
 {
     _filename         = filename;
     _appConfiguration = appConfiguration;
 }