/// <inheritdoc />
        public async Task RunAsync(CancellationToken cancellationToken)
        {
            using (cancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken))
                using (var fsWatcher = updatePath != null ? new FileSystemWatcher(Path.GetDirectoryName(updatePath)) : null)
                {
                    if (fsWatcher != null)
                    {
                        fsWatcher.Created += (a, b) =>
                        {
                            if (b.FullPath == updatePath && File.Exists(b.FullPath))
                            {
                                cancellationTokenSource.Cancel();
                            }
                        };
                        fsWatcher.EnableRaisingEvents = true;
                    }

                    using (var webHost = webHostBuilder.Build())
                        try
                        {
                            logger = webHost.Services.GetRequiredService <ILogger <Server> >();
                            var generalConfigurationOptions = webHost.Services.GetRequiredService <IOptions <GeneralConfiguration> >();
                            generalConfiguration = generalConfigurationOptions.Value;
                            await webHost.RunAsync(cancellationTokenSource.Token).ConfigureAwait(false);
                        }
                        catch (OperationCanceledException)
                        {
                            CheckExceptionPropagation();
                            throw;
                        }
                }

            CheckExceptionPropagation();
        }
 /// <summary>
 /// Construct a <see cref="UserController"/>
 /// </summary>
 /// <param name="databaseContext">The <see cref="IDatabaseContext"/> for the <see cref="ApiController"/></param>
 /// <param name="authenticationContextFactory">The <see cref="IAuthenticationContextFactory"/> for the <see cref="ApiController"/></param>
 /// <param name="systemIdentityFactory">The value of <see cref="systemIdentityFactory"/></param>
 /// <param name="cryptographySuite">The value of <see cref="cryptographySuite"/></param>
 /// <param name="logger">The value of <see cref="logger"/></param>
 /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/></param>
 public UserController(IDatabaseContext databaseContext, IAuthenticationContextFactory authenticationContextFactory, ISystemIdentityFactory systemIdentityFactory, ICryptographySuite cryptographySuite, ILogger <UserController> logger, IOptions <GeneralConfiguration> generalConfigurationOptions) : base(databaseContext, authenticationContextFactory, logger, false, true)
 {
     this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
     this.systemIdentityFactory = systemIdentityFactory ?? throw new ArgumentNullException(nameof(systemIdentityFactory));
     this.cryptographySuite     = cryptographySuite ?? throw new ArgumentNullException(nameof(cryptographySuite));
     generalConfiguration       = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
 }
Esempio n. 3
0
        /// <summary>
        /// Считывает конфигурацию из app.config и записывает в <see cref="Conformation"/>.
        /// </summary>
        public static void Init()
        {
            // Подготовка объекта содержащего в себе ноду из файла app.config "GisServicesConfig".
            GisServiceConfiguration section = (GisServiceConfiguration)ConfigurationManager.GetSection("GisServicesConfig");

            // Подготовка объекта содержащего в себе ноду из файла app.config "signingConfig".
            SigningConfiguration sign = (SigningConfiguration)ConfigurationManager.GetSection("signingConfig");

            // Подготовка объекта содержащего в себе ноду из файла app.config "Sender".
            SenderConfiguration sender = (SenderConfiguration)ConfigurationManager.GetSection("Sender");

            // Подготовка объекта содержащего в себе ноду из файла app.config "General".
            GeneralConfiguration general = (GeneralConfiguration)ConfigurationManager.GetSection("General");

            // Заполнение структуры сведениями из конфиг файла.
            Сonformation conf = new Сonformation
            {
                login    = section.Login,
                password = section.Password,
                certificateThumbprint = sign.CertificateThumbprint,
                certificatePassword   = sign.CertificatePassword,

                RIRCorgPPAGUID = section.RIRCorgPPAGUID,
                baseUrl        = section.BaseUrl,
                //schemaVersion         = section.SchemaVersion, TODO удалить если всё норм. ТЕперь берём из базы.
                soapConfiguration = section.SoapConfiguration,
                IsTest            = Convert.ToBoolean(section.IsTest),
                sendTo            = sender.SendTo,
                timeInterval      = Convert.ToInt32(general.TimeInterval) * 60000,
                amountAttempt     = Convert.ToInt32(general.AmountAttempt)
            };

            conformation = conf;
        }
Esempio n. 4
0
 /// <summary>
 /// Construct a <see cref="InstanceController"/>
 /// </summary>
 /// <param name="databaseContext">The <see cref="IDatabaseContext"/> for the <see cref="ApiController"/></param>
 /// <param name="authenticationContextFactory">The <see cref="IAuthenticationContextFactory"/> for the <see cref="ApiController"/></param>
 /// <param name="jobManager">The value of <see cref="jobManager"/></param>
 /// <param name="instanceManager">The value of <see cref="instanceManager"/></param>
 /// <param name="ioManager">The value of <see cref="ioManager"/></param>
 /// <param name="platformIdentifier">The value of <see cref="platformIdentifier"/></param>
 /// <param name="portAllocator">The value of <see cref="IPortAllocator"/>.</param>
 /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/>.</param>
 /// <param name="swarmConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="swarmConfiguration"/>.</param>
 /// <param name="logger">The <see cref="ILogger"/> for the <see cref="ApiController"/>.</param>
 public InstanceController(
     IDatabaseContext databaseContext,
     IAuthenticationContextFactory authenticationContextFactory,
     IJobManager jobManager,
     IInstanceManager instanceManager,
     IIOManager ioManager,
     IPortAllocator portAllocator,
     IPlatformIdentifier platformIdentifier,
     IOptions <GeneralConfiguration> generalConfigurationOptions,
     IOptions <SwarmConfiguration> swarmConfigurationOptions,
     ILogger <InstanceController> logger)
     : base(
         databaseContext,
         authenticationContextFactory,
         logger,
         true)
 {
     this.jobManager         = jobManager ?? throw new ArgumentNullException(nameof(jobManager));
     this.instanceManager    = instanceManager ?? throw new ArgumentNullException(nameof(instanceManager));
     this.ioManager          = ioManager ?? throw new ArgumentNullException(nameof(ioManager));
     this.platformIdentifier = platformIdentifier ?? throw new ArgumentNullException(nameof(platformIdentifier));
     this.portAllocator      = portAllocator ?? throw new ArgumentNullException(nameof(portAllocator));
     generalConfiguration    = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
     swarmConfiguration      = swarmConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(swarmConfigurationOptions));
 }
Esempio n. 5
0
 /// <summary>
 /// Construct a <see cref="ChangelogModule"/>
 /// </summary>
 /// <param name="dataStoreFactory">The <see cref="IDataStoreFactory{TModule}"/> to create <see cref="dataStore"/> from</param>
 /// <param name="stringLocalizer">The value of <see cref="stringLocalizer"/></param>
 /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/></param>
 /// <param name="gitHubManager">The value of <see cref="gitHubManager"/></param>
 public ChangelogModule(IDataStoreFactory <ChangelogModule> dataStoreFactory, IStringLocalizer <ChangelogModule> stringLocalizer, IOptions <GeneralConfiguration> generalConfigurationOptions, IGitHubManager gitHubManager)
 {
     this.stringLocalizer = stringLocalizer ?? throw new ArgumentNullException(nameof(stringLocalizer));
     this.gitHubManager   = gitHubManager ?? throw new ArgumentNullException(nameof(gitHubManager));
     generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
     dataStore            = dataStoreFactory?.CreateDataStore(this) ?? throw new ArgumentNullException(nameof(dataStoreFactory));
 }
Esempio n. 6
0
        /// <summary>
        /// Construct an <see cref="InstanceManager"/>
        /// </summary>
        /// <param name="instanceFactory">The value of <see cref="instanceFactory"/></param>
        /// <param name="ioManager">The value of <paramref name="ioManager"/></param>
        /// <param name="databaseContextFactory">The value of <paramref name="databaseContextFactory"/></param>
        /// <param name="assemblyInformationProvider">The value of <see cref="assemblyInformationProvider"/></param>
        /// <param name="jobManager">The value of <see cref="jobManager"/></param>
        /// <param name="serverControl">The value of <see cref="serverControl"/></param>
        /// <param name="systemIdentityFactory">The value of <see cref="systemIdentityFactory"/>.</param>
        /// <param name="asyncDelayer">The value of <see cref="asyncDelayer"/>.</param>
        /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/>.</param>
        /// <param name="logger">The value of <see cref="logger"/></param>
        public InstanceManager(
            IInstanceFactory instanceFactory,
            IIOManager ioManager,
            IDatabaseContextFactory databaseContextFactory,
            IAssemblyInformationProvider assemblyInformationProvider,
            IJobManager jobManager,
            IServerControl serverControl,
            ISystemIdentityFactory systemIdentityFactory,
            IAsyncDelayer asyncDelayer,
            IOptions <GeneralConfiguration> generalConfigurationOptions,
            ILogger <InstanceManager> logger)
        {
            this.instanceFactory             = instanceFactory ?? throw new ArgumentNullException(nameof(instanceFactory));
            this.ioManager                   = ioManager ?? throw new ArgumentNullException(nameof(ioManager));
            this.databaseContextFactory      = databaseContextFactory ?? throw new ArgumentNullException(nameof(databaseContextFactory));
            this.assemblyInformationProvider = assemblyInformationProvider ?? throw new ArgumentNullException(nameof(assemblyInformationProvider));
            this.jobManager                  = jobManager ?? throw new ArgumentNullException(nameof(jobManager));
            this.serverControl               = serverControl ?? throw new ArgumentNullException(nameof(serverControl));
            this.systemIdentityFactory       = systemIdentityFactory ?? throw new ArgumentNullException(nameof(systemIdentityFactory));
            this.asyncDelayer                = asyncDelayer ?? throw new ArgumentNullException(nameof(asyncDelayer));
            generalConfiguration             = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
            this.logger = logger ?? throw new ArgumentNullException(nameof(logger));

            serverControl.RegisterForRestart(this);

            instances      = new Dictionary <long, IInstance>();
            bridgeHandlers = new Dictionary <string, IBridgeHandler>();
            readyTcs       = new TaskCompletionSource <object>();
        }
        public async Task TestWithUserStupiditiy()
        {
            var mockIOManager           = new Mock <IIOManager>();
            var mockConsole             = new Mock <IConsole>();
            var mockHostingEnvironment  = new Mock <IHostingEnvironment>();
            var mockApplication         = new Mock <IApplication>();
            var mockDBConnectionFactory = new Mock <IDBConnectionFactory>();
            var mockLogger = new Mock <ILogger <SetupWizard> >();
            var mockGeneralConfigurationOptions = new Mock <IOptions <GeneralConfiguration> >();
            var mockPlatformIdentifier          = new Mock <IPlatformIdentifier>();
            var mockAsyncDelayer = new Mock <IAsyncDelayer>();

            var testGeneralConfig = new GeneralConfiguration
            {
                SetupWizardMode = SetupWizardMode.Never
            };

            mockGeneralConfigurationOptions.SetupGet(x => x.Value).Returns(testGeneralConfig).Verifiable();

            var wizard = new SetupWizard(mockIOManager.Object, mockConsole.Object, mockHostingEnvironment.Object, mockApplication.Object, mockDBConnectionFactory.Object, mockPlatformIdentifier.Object, mockAsyncDelayer.Object, mockLogger.Object, mockGeneralConfigurationOptions.Object);

            mockPlatformIdentifier.SetupGet(x => x.IsWindows).Returns(true).Verifiable();
            mockAsyncDelayer.Setup(x => x.Delay(It.IsAny <TimeSpan>(), It.IsAny <CancellationToken>())).Returns(Task.CompletedTask).Verifiable();

            Assert.IsFalse(await wizard.CheckRunWizard(default).ConfigureAwait(false));
    private GameObject currentlyMovingObject = null; //when a piece of scenery is being moved, it is referenced to this variable - otherwise, it is normally left null

    void Awake()
    {
        arCamera             = Camera.main;
        appStateManager      = FindObjectOfType <AppStateManager>();
        generalConfiguration = FindObjectOfType <GeneralConfiguration>();
        sceneryUtil          = FindObjectOfType <SceneryUtil>();
    }
Esempio n. 9
0
 /// <summary>
 /// Construct a <see cref="PullRequestController"/>
 /// </summary>
 /// <param name="gitHubManager">The value of <see cref="gitHubManager"/></param>
 /// <param name="stringLocalizer">The value of <see cref="stringLocalizer"/></param>
 /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing value of <see cref="generalConfiguration"/></param>
 /// <param name="githubConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing value of <see cref="generalConfiguration"/></param>
 public PullRequestController(IGitHubManager gitHubManager, IStringLocalizer <PullRequestController> stringLocalizer, IOptions <GeneralConfiguration> generalConfigurationOptions, IOptions <GitHubConfiguration> githubConfigurationOptions)
 {
     this.gitHubManager   = gitHubManager ?? throw new ArgumentNullException(nameof(gitHubManager));
     this.stringLocalizer = stringLocalizer ?? throw new ArgumentNullException(nameof(stringLocalizer));
     generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
     gitHubConfiguration  = githubConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(githubConfigurationOptions));
 }
Esempio n. 10
0
 /// <summary>
 /// Construct a <see cref="RepositoryController"/>
 /// </summary>
 /// <param name="databaseContext">The <see cref="IDatabaseContext"/> for the <see cref="ApiController"/></param>
 /// <param name="authenticationContextFactory">The <see cref="IAuthenticationContextFactory"/> for the <see cref="ApiController"/></param>
 /// <param name="instanceManager">The value of <see cref="instanceManager"/></param>
 /// <param name="gitHubClientFactory">The value of <see cref="gitHubClientFactory"/></param>
 /// <param name="jobManager">The value of <see cref="jobManager"/></param>
 /// <param name="logger">The <see cref="ILogger"/> for the <see cref="ApiController"/></param>
 /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing value of <see cref="generalConfiguration"/></param>
 public RepositoryController(IDatabaseContext databaseContext, IAuthenticationContextFactory authenticationContextFactory, IInstanceManager instanceManager, IGitHubClientFactory gitHubClientFactory, IJobManager jobManager, ILogger <RepositoryController> logger, IOptions <GeneralConfiguration> generalConfigurationOptions) : base(databaseContext, authenticationContextFactory, logger, true, true)
 {
     this.instanceManager     = instanceManager ?? throw new ArgumentNullException(nameof(instanceManager));
     this.gitHubClientFactory = gitHubClientFactory ?? throw new ArgumentNullException(nameof(gitHubClientFactory));
     this.jobManager          = jobManager ?? throw new ArgumentNullException(nameof(jobManager));
     generalConfiguration     = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
 }
Esempio n. 11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="InstanceManager"/> class.
        /// </summary>
        /// <param name="instanceFactory">The value of <see cref="instanceFactory"/>.</param>
        /// <param name="ioManager">The value of <paramref name="ioManager"/>.</param>
        /// <param name="databaseContextFactory">The value of <paramref name="databaseContextFactory"/>.</param>
        /// <param name="assemblyInformationProvider">The value of <see cref="assemblyInformationProvider"/>.</param>
        /// <param name="jobManager">The value of <see cref="jobManager"/>.</param>
        /// <param name="serverControl">The value of <see cref="serverControl"/>.</param>
        /// <param name="systemIdentityFactory">The value of <see cref="systemIdentityFactory"/>.</param>
        /// <param name="asyncDelayer">The value of <see cref="asyncDelayer"/>.</param>
        /// <param name="serverPortProvider">The value of <see cref="serverPortProvider"/>.</param>
        /// <param name="swarmService">The value of <see cref="swarmService"/>.</param>
        /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/>.</param>
        /// <param name="swarmConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="swarmConfiguration"/>.</param>
        /// <param name="logger">The value of <see cref="logger"/>.</param>
        public InstanceManager(
            IInstanceFactory instanceFactory,
            IIOManager ioManager,
            IDatabaseContextFactory databaseContextFactory,
            IAssemblyInformationProvider assemblyInformationProvider,
            IJobManager jobManager,
            IServerControl serverControl,
            ISystemIdentityFactory systemIdentityFactory,
            IAsyncDelayer asyncDelayer,
            IServerPortProvider serverPortProvider,
            ISwarmService swarmService,
            IOptions <GeneralConfiguration> generalConfigurationOptions,
            IOptions <SwarmConfiguration> swarmConfigurationOptions,
            ILogger <InstanceManager> logger)
        {
            this.instanceFactory             = instanceFactory ?? throw new ArgumentNullException(nameof(instanceFactory));
            this.ioManager                   = ioManager ?? throw new ArgumentNullException(nameof(ioManager));
            this.databaseContextFactory      = databaseContextFactory ?? throw new ArgumentNullException(nameof(databaseContextFactory));
            this.assemblyInformationProvider = assemblyInformationProvider ?? throw new ArgumentNullException(nameof(assemblyInformationProvider));
            this.jobManager                  = jobManager ?? throw new ArgumentNullException(nameof(jobManager));
            this.serverControl               = serverControl ?? throw new ArgumentNullException(nameof(serverControl));
            this.systemIdentityFactory       = systemIdentityFactory ?? throw new ArgumentNullException(nameof(systemIdentityFactory));
            this.asyncDelayer                = asyncDelayer ?? throw new ArgumentNullException(nameof(asyncDelayer));
            this.serverPortProvider          = serverPortProvider ?? throw new ArgumentNullException(nameof(serverPortProvider));
            this.swarmService                = swarmService ?? throw new ArgumentNullException(nameof(swarmService));
            generalConfiguration             = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
            swarmConfiguration               = swarmConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(swarmConfigurationOptions));
            this.logger = logger ?? throw new ArgumentNullException(nameof(logger));

            instances      = new Dictionary <long, InstanceContainer>();
            bridgeHandlers = new Dictionary <string, IBridgeHandler>();
            readyTcs       = new TaskCompletionSource <object>();
            instanceStateChangeSemaphore = new SemaphoreSlim(1);
        }
 /// <summary>
 /// Construct a <see cref="HomeController"/>
 /// </summary>
 /// <param name="databaseContext">The <see cref="IDatabaseContext"/> for the <see cref="ApiController"/></param>
 /// <param name="authenticationContextFactory">The <see cref="IAuthenticationContextFactory"/> for the <see cref="ApiController"/></param>
 /// <param name="tokenFactory">The value of <see cref="tokenFactory"/></param>
 /// <param name="systemIdentityFactory">The value of <see cref="systemIdentityFactory"/></param>
 /// <param name="cryptographySuite">The value of <see cref="cryptographySuite"/></param>
 /// <param name="assemblyInformationProvider">The value of <see cref="assemblyInformationProvider"/></param>
 /// <param name="identityCache">The value of <see cref="identityCache"/></param>
 /// <param name="oAuthProviders">The value of <see cref="oAuthProviders"/>.</param>
 /// <param name="platformIdentifier">The value of <see cref="platformIdentifier"/>.</param>
 /// <param name="browserResolver">The value of <see cref="browserResolver"/></param>
 /// <param name="swarmService">The value of <see cref="swarmService"/>.</param>
 /// <param name="serverControl">The value of <see cref="serverControl"/>.</param>
 /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/>.</param>
 /// <param name="controlPanelConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="controlPanelConfiguration"/></param>
 /// <param name="logger">The <see cref="ILogger"/> for the <see cref="ApiController"/></param>
 public HomeController(
     IDatabaseContext databaseContext,
     IAuthenticationContextFactory authenticationContextFactory,
     ITokenFactory tokenFactory,
     ISystemIdentityFactory systemIdentityFactory,
     ICryptographySuite cryptographySuite,
     IAssemblyInformationProvider assemblyInformationProvider,
     IIdentityCache identityCache,
     IOAuthProviders oAuthProviders,
     IPlatformIdentifier platformIdentifier,
     IBrowserResolver browserResolver,
     ISwarmService swarmService,
     IServerControl serverControl,
     IOptions <GeneralConfiguration> generalConfigurationOptions,
     IOptions <ControlPanelConfiguration> controlPanelConfigurationOptions,
     ILogger <HomeController> logger)
     : base(
         databaseContext,
         authenticationContextFactory,
         logger,
         false)
 {
     this.tokenFactory                = tokenFactory ?? throw new ArgumentNullException(nameof(tokenFactory));
     this.systemIdentityFactory       = systemIdentityFactory ?? throw new ArgumentNullException(nameof(systemIdentityFactory));
     this.cryptographySuite           = cryptographySuite ?? throw new ArgumentNullException(nameof(cryptographySuite));
     this.assemblyInformationProvider = assemblyInformationProvider ?? throw new ArgumentNullException(nameof(assemblyInformationProvider));
     this.identityCache               = identityCache ?? throw new ArgumentNullException(nameof(identityCache));
     this.platformIdentifier          = platformIdentifier ?? throw new ArgumentNullException(nameof(platformIdentifier));
     this.oAuthProviders              = oAuthProviders ?? throw new ArgumentNullException(nameof(oAuthProviders));
     this.browserResolver             = browserResolver ?? throw new ArgumentNullException(nameof(browserResolver));
     this.swarmService                = swarmService ?? throw new ArgumentNullException(nameof(swarmService));
     this.serverControl               = serverControl ?? throw new ArgumentNullException(nameof(serverControl));
     generalConfiguration             = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
     controlPanelConfiguration        = controlPanelConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(controlPanelConfigurationOptions));
 }
 void Awake()
 {
     appStateManager      = FindObjectOfType <AppStateManager>();
     generalConfiguration = FindObjectOfType <GeneralConfiguration>();
     arRaycastManager     = FindObjectOfType <ARRaycastManager>();
     placementCursor      = Instantiate(generalConfiguration.placementCursorPrefab) as GameObject;
 }
 /// <summary>
 /// Construct a <see cref="DmeConfigurationController"/>
 /// </summary>
 /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/></param>
 /// <param name="databaseContext">The value of <see cref="databaseContext"/></param>
 /// <param name="gitHubManager">The value of <see cref="gitHubManager"/></param>
 /// <param name="stringLocalizer">The value of <see cref="stringLocalizer"/></param>
 public DmeConfigurationController(IOptions <GeneralConfiguration> generalConfigurationOptions, IDatabaseContext databaseContext, IGitHubManager gitHubManager, IStringLocalizer <DmeConfigurationController> stringLocalizer)
 {
     generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
     this.databaseContext = databaseContext ?? throw new ArgumentNullException(nameof(databaseContext));
     this.gitHubManager   = gitHubManager ?? throw new ArgumentNullException(nameof(gitHubManager));
     this.stringLocalizer = stringLocalizer ?? throw new ArgumentNullException(nameof(stringLocalizer));
 }
Esempio n. 15
0
        /// <summary>
        /// Construct an <see cref="Instance"/>
        /// </summary>
        /// <param name="metadata">The value of <see cref="metadata"/></param>
        /// <param name="repositoryManager">The value of <see cref="RepositoryManager"/></param>
        /// <param name="byondManager">The value of <see cref="ByondManager"/></param>
        /// <param name="dreamMaker">The value of <see cref="DreamMaker"/></param>
        /// <param name="watchdog">The value of <see cref="Watchdog"/></param>
        /// <param name="chat">The value of <see cref="Chat"/></param>
        /// <param name="configuration">The value of <see cref="Configuration"/></param>
        /// <param name="dmbFactory">The value of <see cref="dmbFactory"/></param>
        /// <param name="jobManager">The value of <see cref="jobManager"/></param>
        /// <param name="eventConsumer">The value of <see cref="eventConsumer"/></param>
        /// <param name="gitHubClientFactory">The value of <see cref="gitHubClientFactory"/>.</param>
        /// <param name="logger">The value of <see cref="logger"/></param>
        /// <param name="generalConfiguration">The value of <see cref="generalConfiguration"/>.</param>
        public Instance(
            Api.Models.Instance metadata,
            IRepositoryManager repositoryManager,
            IByondManager byondManager,
            IDreamMaker dreamMaker,
            IWatchdog watchdog,
            IChatManager chat,
            StaticFiles.IConfiguration
            configuration,
            IDmbFactory dmbFactory,
            IJobManager jobManager,
            IEventConsumer eventConsumer,
            IGitHubClientFactory gitHubClientFactory,
            ILogger <Instance> logger,
            GeneralConfiguration generalConfiguration)
        {
            this.metadata     = metadata ?? throw new ArgumentNullException(nameof(metadata));
            RepositoryManager = repositoryManager ?? throw new ArgumentNullException(nameof(repositoryManager));
            ByondManager      = byondManager ?? throw new ArgumentNullException(nameof(byondManager));
            DreamMaker        = dreamMaker ?? throw new ArgumentNullException(nameof(dreamMaker));
            Watchdog          = watchdog ?? throw new ArgumentNullException(nameof(watchdog));
            Chat                      = chat ?? throw new ArgumentNullException(nameof(chat));
            Configuration             = configuration ?? throw new ArgumentNullException(nameof(configuration));
            this.dmbFactory           = dmbFactory ?? throw new ArgumentNullException(nameof(dmbFactory));
            this.jobManager           = jobManager ?? throw new ArgumentNullException(nameof(jobManager));
            this.eventConsumer        = eventConsumer ?? throw new ArgumentNullException(nameof(eventConsumer));
            this.gitHubClientFactory  = gitHubClientFactory ?? throw new ArgumentNullException(nameof(gitHubClientFactory));
            this.logger               = logger ?? throw new ArgumentNullException(nameof(logger));
            this.generalConfiguration = generalConfiguration ?? throw new ArgumentNullException(nameof(generalConfiguration));

            timerLock = new object();
        }
Esempio n. 16
0
        public bool CanDisplayIcon(string moduleId, int pageId, int iconId)
        {
            var game          = TCAdmin.GameHosting.SDK.Objects.Game.GetSelectedGame();
            var generalConfig = GeneralConfiguration.GetConfigurationForGame(game);
            var providerid    = iconId - 4890;

            if (generalConfig.SingleIcon)
            {
                return(providerid == 1 && CustomModBase.GetCustomModBases()
                       .Select(customModBase =>
                               customModBase.GetConfigurationForGame(game).ToObject <CustomModProviderConfiguration>())
                       .Any(config => config != null && config.Enabled));
            }

            var providers = CustomModBase.GetCustomModBases();

            var provider = providers.SingleOrDefault(p => p.Id == providerid);

            if (provider != null)
            {
                var config = provider.GetConfigurationForGame(game).ToObject <CustomModProviderConfiguration>();
                return(config != null && config.Enabled);
            }

            return(false);
        }
Esempio n. 17
0
        public async Task TestCreateBasicClient()
        {
            var mockApp = new Mock <IAssemblyInformationProvider>();

            mockApp.SetupGet(x => x.ProductInfoHeaderValue).Returns(new ProductInfoHeaderValue("TGSTests", "1.2.3")).Verifiable();

            var mockOptions = new Mock <IOptions <GeneralConfiguration> >();

            var gc = new GeneralConfiguration();

            Assert.IsNull(gc.GitHubAccessToken);
            mockOptions.SetupGet(x => x.Value).Returns(gc);
            var factory = new GitHubClientFactory(mockApp.Object, mockOptions.Object);

            var client = factory.CreateClient();

            Assert.IsNotNull(client);
            var credentials = await client.Connection.CredentialStore.GetCredentials().ConfigureAwait(false);

            Assert.AreEqual(AuthenticationType.Anonymous, credentials.AuthenticationType);

            gc.GitHubAccessToken = "asdfasdfasdfasdfasdfasdf";
            client = factory.CreateClient();
            Assert.IsNotNull(client);
            credentials = await client.Connection.CredentialStore.GetCredentials().ConfigureAwait(false);

            Assert.AreEqual(AuthenticationType.Oauth, credentials.AuthenticationType);

            mockApp.VerifyAll();
        }
 /// <summary>
 /// Construct an <see cref="AdministrationController"/>
 /// </summary>
 /// <param name="databaseContext">The <see cref="IDatabaseContext"/> for the <see cref="ApiController"/></param>
 /// <param name="authenticationContextFactory">The <see cref="IAuthenticationContextFactory"/> for the <see cref="ApiController"/></param>
 /// <param name="gitHubClientFactory">The value of <see cref="gitHubClientFactory"/></param>
 /// <param name="serverUpdater">The value of <see cref="serverUpdater"/></param>
 /// <param name="application">The value of <see cref="application"/></param>
 /// <param name="ioManager">The value of <see cref="ioManager"/></param>
 /// <param name="platformIdentifier">The value of <see cref="platformIdentifier"/></param>
 /// <param name="logger">The <see cref="ILogger"/> for the <see cref="ApiController"/></param>
 /// <param name="updatesConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing value of <see cref="updatesConfiguration"/></param>
 /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing value of <see cref="generalConfiguration"/></param>
 public AdministrationController(
     IDatabaseContext databaseContext,
     IAuthenticationContextFactory authenticationContextFactory,
     IGitHubClientFactory gitHubClientFactory,
     IServerControl serverUpdater,
     IApplication application,
     IIOManager ioManager,
     IPlatformIdentifier platformIdentifier,
     ILogger <AdministrationController> logger,
     IOptions <UpdatesConfiguration> updatesConfigurationOptions,
     IOptions <GeneralConfiguration> generalConfigurationOptions)
     : base(
         databaseContext,
         authenticationContextFactory,
         logger,
         false,
         true)
 {
     this.gitHubClientFactory = gitHubClientFactory ?? throw new ArgumentNullException(nameof(gitHubClientFactory));
     this.serverUpdater       = serverUpdater ?? throw new ArgumentNullException(nameof(serverUpdater));
     this.application         = application ?? throw new ArgumentNullException(nameof(application));
     this.ioManager           = ioManager ?? throw new ArgumentNullException(nameof(ioManager));
     this.platformIdentifier  = platformIdentifier ?? throw new ArgumentNullException(nameof(platformIdentifier));
     updatesConfiguration     = updatesConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(updatesConfigurationOptions));
     generalConfiguration     = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
 }
Esempio n. 19
0
    void Awake()
    {
        appStateManager      = FindObjectOfType <AppStateManager>();
        generalConfiguration = FindObjectOfType <GeneralConfiguration>();
        spatialAnchorManager = FindObjectOfType <SpatialAnchorManager>();

        SetupCloudSessionAsync();
    }
Esempio n. 20
0
 /// <summary>
 /// Construct a <see cref="GeneratorFactory"/>
 /// </summary>
 /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/></param>
 public GeneratorFactory(IOptions <GeneralConfiguration> generalConfigurationOptions)
 {
     generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
     if (generalConfiguration.ProcessLimit > 0)
     {
         semaphore = new SemaphoreSlim((int)generalConfiguration.ProcessLimit);
     }
 }
Esempio n. 21
0
 public ActionResult GeneralConfigure(GeneralConfiguration model)
 {
     new DatabaseConfiguration <GeneralConfiguration>(Globals.ModuleId, "GeneralConfiguration").SetConfiguration(model);
     return(new JsonNetResult(new
     {
         Message = "General Configuration successfully saved."
     }));
 }
 /// <summary>
 /// Construct a <see cref="ModulesController"/>
 /// </summary>
 /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing value of <see cref="generalConfiguration"/></param>
 /// <param name="logger">The value of <see cref="logger"/></param>
 /// <param name="stringLocalizer">The value of <see cref="stringLocalizer"/></param>
 /// <param name="gitHubManager">The value of <see cref="gitHubManager"/></param>
 /// <param name="moduleManager">The value of <see cref="moduleManager"/></param>
 public ModulesController(IOptions <GeneralConfiguration> generalConfigurationOptions, ILogger <ModulesController> logger, IStringLocalizer <ModulesController> stringLocalizer, IGitHubManager gitHubManager, IModuleManager moduleManager)
 {
     generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
     this.logger          = logger ?? throw new ArgumentNullException(nameof(logger));
     this.stringLocalizer = stringLocalizer ?? throw new ArgumentNullException(nameof(stringLocalizer));
     this.gitHubManager   = gitHubManager ?? throw new ArgumentNullException(nameof(gitHubManager));
     this.moduleManager   = moduleManager ?? throw new ArgumentNullException(nameof(moduleManager));
 }
Esempio n. 23
0
 private GeneralConfiguration getGenConfigInstance()
 {
     if (genConfig == null)
     {
         genConfig = new GeneralConfiguration();
     }
     return(genConfig);
 }
 /// <summary>
 /// Construct a <see cref="ChangelogGeneratorModule"/>
 /// </summary>
 /// <param name="dataStoreFactory">The <see cref="IDataStoreFactory{TModule}"/> to create <see cref="dataStore"/> from</param>
 /// <param name="stringLocalizer">The value of <see cref="stringLocalizer"/></param>
 /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/></param>
 /// <param name="ioManager">The value of <see cref="ioManager"/></param>
 /// <param name="repository">The value of <see cref="repository"/></param>
 public ChangelogGeneratorModule(IDataStoreFactory <ChangelogGeneratorModule> dataStoreFactory, IStringLocalizer <ChangelogGeneratorModule> stringLocalizer, IOptions <GeneralConfiguration> generalConfigurationOptions, IIOManager ioManager, IRepository repository)
 {
     this.stringLocalizer = stringLocalizer ?? throw new ArgumentNullException(nameof(stringLocalizer));
     this.ioManager       = ioManager ?? throw new ArgumentNullException(nameof(ioManager));
     this.repository      = repository ?? throw new ArgumentNullException(nameof(repository));
     generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
     dataStore            = dataStoreFactory?.CreateDataStore(this) ?? throw new ArgumentNullException(nameof(dataStoreFactory));
 }
 /// <summary>
 /// Construct an <see cref="AutoMergeHandler"/>
 /// </summary>
 /// <param name="_serviceProvider">The value of <see cref="serviceProvider"/></param>
 /// <param name="_logger">The value of <see cref="logger"/></param>
 /// <param name="_stringLocalizer">The value of <see cref="stringLocalizer"/></param>
 /// <param name="_backgroundJobClient">The value of <see cref="backgroundJobClient"/></param>
 /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/></param>
 public AutoMergeHandler(IServiceProvider _serviceProvider, ILogger <AutoMergeHandler> _logger, IStringLocalizer <AutoMergeHandler> _stringLocalizer, IBackgroundJobClient _backgroundJobClient, IOptions <GeneralConfiguration> generalConfigurationOptions)
 {
     serviceProvider      = _serviceProvider ?? throw new ArgumentNullException(nameof(_serviceProvider));
     logger               = _logger ?? throw new ArgumentNullException(nameof(_logger));
     stringLocalizer      = _stringLocalizer ?? throw new ArgumentNullException(nameof(_stringLocalizer));
     backgroundJobClient  = _backgroundJobClient ?? throw new ArgumentNullException(nameof(_backgroundJobClient));
     generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
     semaphore            = new SemaphoreSlim(1);
 }
Esempio n. 26
0
 /// <summary>
 /// Construct a <see cref="PayloadProcessor"/>
 /// </summary>
 /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/></param>
 /// <param name="serviceProvider">The value of <see cref="serviceProvider"/></param>
 /// <param name="logger">The value of <see cref="logger"/></param>
 /// <param name="stringLocalizer">The value of <see cref="stringLocalizer"/></param>
 /// <param name="backgroundJobClient">The value of <see cref="backgroundJobClient"/></param>
 /// <param name="diffGenerator">The value of <see cref="diffGenerator"/></param>
 public PayloadProcessor(IOptions <GeneralConfiguration> generalConfigurationOptions, IServiceProvider serviceProvider, ILogger <PayloadProcessor> logger, IStringLocalizer <PayloadProcessor> stringLocalizer, IBackgroundJobClient backgroundJobClient, IDiffGenerator diffGenerator)
 {
     generalConfiguration     = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
     this.serviceProvider     = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
     this.logger              = logger ?? throw new ArgumentNullException(nameof(logger));
     this.stringLocalizer     = stringLocalizer ?? throw new ArgumentNullException(nameof(stringLocalizer));
     this.backgroundJobClient = backgroundJobClient ?? throw new ArgumentNullException(nameof(backgroundJobClient));
     this.diffGenerator       = diffGenerator ?? throw new ArgumentNullException(nameof(diffGenerator));
 }
Esempio n. 27
0
 /// <summary>
 /// Construct a <see cref="SetupWizard"/>
 /// </summary>
 /// <param name="ioManager">The value of <see cref="ioManager"/></param>
 /// <param name="console">The value of <see cref="console"/></param>
 /// <param name="hostingEnvironment">The value of <see cref="hostingEnvironment"/></param>
 /// <param name="application">The value of <see cref="application"/></param>
 /// <param name="dbConnectionFactory">The value of <see cref="dbConnectionFactory"/></param>
 /// <param name="logger">The value of <see cref="logger"/></param>
 /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/></param>
 public SetupWizard(IIOManager ioManager, IConsole console, IHostingEnvironment hostingEnvironment, IApplication application, IDBConnectionFactory dbConnectionFactory, ILogger <SetupWizard> logger, IOptions <GeneralConfiguration> generalConfigurationOptions)
 {
     this.ioManager           = ioManager ?? throw new ArgumentNullException(nameof(ioManager));
     this.console             = console ?? throw new ArgumentNullException(nameof(console));
     this.hostingEnvironment  = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment));
     this.application         = application ?? throw new ArgumentNullException(nameof(application));
     this.dbConnectionFactory = dbConnectionFactory ?? throw new ArgumentNullException(nameof(dbConnectionFactory));
     this.logger          = logger ?? throw new ArgumentNullException(nameof(logger));
     generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
 }
Esempio n. 28
0
 /// <summary>
 /// Construct a <see cref="GitHubManager"/>
 /// </summary>
 /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/></param>
 /// <param name="gitHubConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="gitHubConfiguration"/></param>
 /// <param name="_databaseContext">The value of <see cref="databaseContext"/></param>
 /// <param name="_logger">The value of <see cref="logger"/></param>
 /// <param name="_gitHubClientFactory">The value of <see cref="gitHubClientFactory"/></param>
 public GitHubManager(IOptions <GeneralConfiguration> generalConfigurationOptions, IOptions <GitHubConfiguration> gitHubConfigurationOptions, IDatabaseContext _databaseContext, ILogger <GitHubManager> _logger, IGitHubClientFactory _gitHubClientFactory)
 {
     gitHubConfiguration  = gitHubConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(gitHubConfigurationOptions));
     generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
     logger              = _logger ?? throw new ArgumentNullException(nameof(_logger));
     databaseContext     = _databaseContext ?? throw new ArgumentNullException(nameof(_databaseContext));
     gitHubClientFactory = _gitHubClientFactory ?? throw new ArgumentNullException(nameof(_gitHubClientFactory));
     gitHubClient        = gitHubClientFactory.CreateGitHubClient(gitHubConfiguration.PersonalAccessToken);
     semaphore           = new SemaphoreSlim(1);
 }
 /// <summary>
 /// Construct a <see cref="WatchdogFactory"/>
 /// </summary>
 /// <param name="serverControl">The value of <see cref="ServerControl"/></param>
 /// <param name="loggerFactory">The value of <see cref="LoggerFactory"/></param>
 /// <param name="databaseContextFactory">The value of <see cref="DatabaseContextFactory"/></param>
 /// <param name="byondTopicSender">The value of <see cref="ByondTopicSender"/></param>
 /// <param name="jobManager">The value of <see cref="JobManager"/></param>
 /// <param name="asyncDelayer">The value of <see cref="AsyncDelayer"/></param>
 /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="GeneralConfiguration"/></param>
 public WatchdogFactory(IServerControl serverControl, ILoggerFactory loggerFactory, IDatabaseContextFactory databaseContextFactory, IByondTopicSender byondTopicSender, IJobManager jobManager, IAsyncDelayer asyncDelayer, IOptions <GeneralConfiguration> generalConfigurationOptions)
 {
     ServerControl          = serverControl ?? throw new ArgumentNullException(nameof(serverControl));
     LoggerFactory          = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
     DatabaseContextFactory = databaseContextFactory ?? throw new ArgumentNullException(nameof(databaseContextFactory));
     ByondTopicSender       = byondTopicSender ?? throw new ArgumentNullException(nameof(byondTopicSender));
     JobManager             = jobManager ?? throw new ArgumentNullException(nameof(jobManager));
     AsyncDelayer           = asyncDelayer ?? throw new ArgumentNullException(nameof(asyncDelayer));
     GeneralConfiguration   = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
 }
Esempio n. 30
0
        public ActionResult GeneralConfigure(int id, GeneralConfiguration generalConfiguration)
        {
            TCAdmin.SDK.Cache.ClearCache("__SECURITY");
            var game   = TCAdmin.GameHosting.SDK.Objects.Game.GetSelectedGame();
            var config = GeneralConfiguration.GetConfigurationForGame(game);

            return(config.SetConfigurationForGame(game, generalConfiguration)
                ? this.SendSuccess("Successfully saved the mod settings")
                : this.SendError("Unable to save custom mod settings!"));
        }