Example #1
0
        public static void ConfigureWindsor(string assemblyName, HttpConfiguration configuration)
        {
            var container = new WindsorContainer();

            var dependencyInstaller = new DependencyInstaller();

            dependencyInstaller.Install(container, null);

            var apiInstaller = new ApiControllerInstaller(assemblyName);

            apiInstaller.Install(container, null);

            container.Kernel.Resolver.AddSubResolver(new CollectionResolver(container.Kernel, true));
            var dependencyResolver = new ApiResolver(container);

            configuration.DependencyResolver = dependencyResolver;

            var installerValidators = new ValidatorsInstaller();

            installerValidators.Install(container, null);

            var servicesInstaller = new ServiceInstaller();

            servicesInstaller.Install(container, null);

            FluentValidationModelValidatorProvider.Configure(provider =>
            {
                provider.ValidatorFactory = container.Resolve <IValidatorFactory>();
            });
        }
Example #2
0
        // This method gets called by a runtime.
        // Use this method to add services to the container
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCaching();

            services.AddSession(o =>
            {
                o.IdleTimeout = TimeSpan.FromSeconds(10);
            });

            services.AddMvc(options =>
            {
                options.Filters.Add(new GlobalExceptionFilter());
            });
            services.Configure <AppSettings>(Configuration.GetSection("AppSettings"));
            var appSettings = Configuration.Get <AppSettings>();

            key          = RSAKeyUtils.GetKey();
            tokenOptions = new TokenAuthOptions("ExampleAudience", "ExampleIssuer", key);
            services.AddInstance <TokenAuthOptions>(tokenOptions);
            services.AddAuthorization(auth =>
            {
                auth.AddPolicy(TokenAuthOptions.Scheme, new AuthorizationPolicyBuilder()
                               .AddAuthenticationSchemes(TokenAuthOptions.Scheme)
                               .RequireAuthenticatedUser()
                               .AddRequirements(new TokenAuthRequirement())
                               .Build());
            });

            DependencyInstaller.InjectDependencies(services, this.Configuration);
            _logger.LogInformation("Configuring Services");
        }
Example #3
0
        public static void Setup(string assemblyName)
        {
            var container = new WindsorContainer();

            var installer = new ControllersInstaller(assemblyName);

            installer.Install(container, null);

            container.Register(Component.For <IWindsorContainer>());

            var installerValidators = new ValidatorsInstaller();

            installerValidators.Install(container, null);

            var dependencyInstaller = new DependencyInstaller();

            dependencyInstaller.Install(container, null);

            var servicesInstaller = new ServiceInstaller();

            servicesInstaller.Install(container, null);

            var controllerFactory = new WindsorControllerFactory(container.Kernel);

            ControllerBuilder.Current.SetControllerFactory(controllerFactory);

            FluentValidationModelValidatorProvider.Configure(provider =>
            {
                provider.ValidatorFactory = container.Resolve <IValidatorFactory>();
            });
        }
 public void InstallNSwag_Invokes_Npm(
     [Frozen] INpmInstaller npm,
     DependencyInstaller sut)
 {
     sut.InstallNSwag();
     Mock.Get(npm)
     .Verify(c => c.InstallNpmPackage("nswag"));
 }
 public void InstallAutoRest_Invokes_Npm(
     [Frozen] INpmInstaller npm,
     DependencyInstaller sut)
 {
     sut.InstallAutoRest();
     Mock.Get(npm)
     .Verify(c => c.InstallNpmPackage("autorest"));
 }
        private void InstallHelperApks()
        {
            var dependencyInstaller = new DependencyInstaller();

            if (Configuration.Dependencies == DependencyHandling.AlwaysInstall)
            {
                dependencyInstaller.InstallDependencies(Adb, Configuration);
            }
            else if (Configuration.Dependencies == DependencyHandling.InstallIfMissing)
            {
                dependencyInstaller.InstallDependenciesIfMissing(Adb, Activity, Configuration);
            }
        }
 public void InstallSwaggerCodegen_Invokes_DownloadFile(
     [Frozen] IFileDownloader downloader,
     DependencyInstaller sut)
 {
     sut.InstallSwaggerCodegen();
     Mock.Get(downloader)
     .Verify(
         c => c.DownloadFile(
             "swagger-codegen-cli.jar",
             Resource.SwaggerCodegenCli_MD5,
             Resource.SwaggerCodegenCli_DownloadUrl,
             false));
 }
 public void InstallOpenApiGenerator_Invokes_DownloadFile(
     [Frozen] IFileDownloader downloader,
     DependencyInstaller sut)
 {
     sut.InstallOpenApiGenerator();
     Mock.Get(downloader)
     .Verify(
         c => c.DownloadFile(
             "openapi-generator-cli.jar",
             Resource.OpenApiGenerator_MD5,
             Resource.OpenApiGenerator_DownloadUrl,
             false));
 }
Example #9
0
        public void Proceed(Context context)
        {
            var pack       = context.Pack;
            var options    = context.Options;
            var settings   = context.Settings;
            var fileSystem = context.FileSystem;

            IEnumerable <Artifact> dependencies = pack.Deps;

            if (options.FilterOn)
            {
                dependencies =
                    DependencyResolver.FilterArtifacts(dependencies, options.FilterValue);
            }

            var installer = new DependencyInstaller();

            installer.FlatFolder = fileSystem.FlatFolder;

            Exception lastException = null;
            var       success       = false;

            foreach (var uri in settings.RepositoryUris)
            {
                try
                {
                    installer.InstallDependencies(uri, fileSystem.DepsFolder, dependencies);
                    success = true;
                    break;
                }
                catch (Exception ex)
                {
                    lastException = ex;
                }
            }

            if (!success)
            {
                throw new Exception(lastException.Message, lastException);
            }
        }
Example #10
0
        public async Task InstallSelected(bool silent)
        {
            var list   = this.FoundAssemblies.Where(a => a.InstallChecked).ToList();
            var amount = this.FoundAssemblies.Count(a => a.InstallChecked);

            try
            {
                var di = new DependencyInstaller(list.Select(a => a.PathToProjectFile).ToList());
                await di.SatisfyAsync();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            await MainWindow.Instance.PrepareAssemblies(list, true, true);

            foreach (var assembly in list)
            {
                if (File.Exists(assembly.PathToBinary))
                {
                    Config.Instance.SelectedProfile.InstalledAssemblies.Add(assembly);
                    amount--;
                }
            }

            if (silent)
            {
                return;
            }

            if (amount == 0)
            {
                this.AfterInstallMessage(Utility.GetMultiLanguageText("SuccessfullyInstalled"), true);
            }
            else
            {
                this.AfterInstallMessage(Utility.GetMultiLanguageText("ErrorInstalling"), true);
            }
        }
Example #11
0
    private void OnApplySelfUpdate(string newUpdateDir)
    {
        var updates = Task.Run(() => DependencyInstaller.GetMissingRuntimeUrls(newUpdateDir)).GetAwaiter().GetResult();

        if (updates.Count <= 0)
        {
            return;
        }

        ActionWrappers.ExecuteWithApplicationDispatcher(() =>
        {
            // Install Updates
            using var tempFolder = new TemporaryFolderAllocation();

            // Display runtime invoke info.
            Actions.DisplayMessagebox.Invoke(Resources.RuntimeUpdateRequiredTitle.Get(), Resources.RuntimeUpdateRequiredDescription.Get(), new Actions.DisplayMessageBoxParams {
                StartupLocation = Actions.WindowStartupLocation.CenterScreen
            });

            Task.Run(() => DependencyInstaller.DownloadAndInstallRuntimesAsync(updates, tempFolder.FolderPath, null, null)).Wait();
        });
    }
Example #12
0
        public async Task PrepareAssemblies(
            IEnumerable <LeagueSharpAssembly> assemblies,
            bool update,
            bool compile)
        {
            this.Working = true;
            var leagueSharpAssemblies = assemblies as IList <LeagueSharpAssembly> ?? assemblies.ToList();

            await Task.Factory.StartNew(
                () =>
            {
                if (update)
                {
                    var updateList = leagueSharpAssemblies.GroupBy(a => a.SvnUrl).Select(g => g.First()).ToList();

                    Parallel.ForEach(
                        updateList,
                        new ParallelOptions {
                        MaxDegreeOfParallelism = this.Config.Workers
                    },
                        (assembly, state) =>
                    {
                        assembly.Update();
                        if (this.AssembliesWorker.CancellationPending)
                        {
                            this.AssembliesWorkerCancelled = true;
                            state.Break();
                        }
                    });
                }
            });

            try
            {
                var di = new DependencyInstaller(leagueSharpAssemblies.Select(a => a.PathToProjectFile).ToList());
                await di.SatisfyAsync();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            await Task.Factory.StartNew(
                () =>
            {
                if (compile)
                {
                    var list =
                        leagueSharpAssemblies.OrderByDescending(a => a.Type == AssemblyType.Library)
                        .ThenByDescending(a => a.Name.StartsWith("LeagueSharp."))
                        .ToList();

                    foreach (var assembly in list)
                    {
                        assembly.Compile();

                        if (this.AssembliesWorker.CancellationPending)
                        {
                            this.AssembliesWorkerCancelled = true;
                            break;
                        }
                    }
                }
            });

            Injection.PrepareDone = true;

            await Task.Factory.StartNew(
                () =>
            {
                ProjectCollection.GlobalProjectCollection.UnloadAllProjects();

                if (this.AssembliesWorkerCancelled)
                {
                    this.Close();
                }
            });

            if (!this.Config.EnableDebug)
            {
                foreach (var file in Directory.EnumerateFiles(Directories.CoreDirectory, "*.pdb"))
                {
                    try
                    {
                        File.Delete(file);
                    }
                    catch
                    {
                        // ignored
                    }
                }

                foreach (var file in Directory.EnumerateFiles(Directories.AssembliesDir, "*.pdb"))
                {
                    try
                    {
                        File.Delete(file);
                    }
                    catch
                    {
                        // ignored
                    }
                }
            }

            this.Working = false;
        }
Example #13
0
        private void DoWork()
        {
            try
            {
                Resources.InitUpdaterDirectories();

                if (_frameworkUpdate != null)
                {
                    string frameworkFile = Path.Combine(Resources.DownloadsDir, "framework.zip");
                    try
                    {
                        lock (_lock)
                        {
                            Logger.Current.Write(LogInfoLevel.Info, "Downloading framework update...");
                            _currentDownloader = new FileDownloader(_frameworkUpdate, frameworkFile, _frameworkUpdateHash, null);
                            _currentTask       = _currentDownloader;
                            View.Invoke(() =>
                            {
                                View.Details     = "Downloading MGDF framework update...";
                                View.AllowCancel = true;
                            });
                        }
                        var result = _currentDownloader.Start();

                        lock (_lock)
                        {
                            _currentDownloader = null;
                            View.Invoke(() => View.AllowCancel = false);
                        }

                        if (result == LongRunningTaskResult.Cancelled)
                        {
                            _workerThread = null;
                            View.Invoke(CloseView);
                            return;
                        }
                        else if (result == LongRunningTaskResult.Error)
                        {
                            //show an error message, though we may still be able to download a game update, so don't bail out yet.
                            ShowError("Download failed", "Failed to download MGDF framework update");
                        }
                        else
                        {
                            lock (_lock)
                            {
                                Logger.Current.Write(LogInfoLevel.Info, "Installing framework update...");
                                //success, now try to install the downloaded update
                                View.Invoke(() => View.Details = "Installing MGDF framework update...");
                                _currentTask = new FrameworkUpdater(frameworkFile);
                            }
                            result = _currentTask.Start();

                            if (result == LongRunningTaskResult.Error)
                            {
                                //show an error message, though we may still be able to download a game update, so don't bail out yet.
                                ShowError("Install failed", "Failed to install MGDF framework update");
                            }
                            else
                            {
                                View.Invoke(() => View.Details = "Installing framework dependencies...");
                                DependencyInstaller.Install();
                            }
                        }
                    }
                    finally
                    {
                        var file = FileSystem.Current.GetFile(frameworkFile);
                        if (file.Exists)
                        {
                            file.DeleteWithTimeout();
                        }
                    }
                }

                if (_gameUpdate != null)
                {
                    string gameUpdateFile = Path.Combine(Resources.DownloadsDir, "update.zip");
                    try
                    {
                        lock (_lock)
                        {
                            Logger.Current.Write(LogInfoLevel.Info, "Downloading game update...");
                            _currentDownloader = new GameDownloader(Game.Current, _gameUpdate, gameUpdateFile, _gameUpdateHash, GetUpdateCredentials);
                            _currentTask       = _currentDownloader;
                            View.Invoke(() =>
                            {
                                View.Details     = "Downloading " + Game.Current.Name + " update...";
                                View.AllowCancel = true;
                            });
                        }
                        var result = _currentDownloader.Start();

                        lock (_lock)
                        {
                            _currentDownloader = null;
                            View.Invoke(() => View.AllowCancel = false);
                        }

                        if (result == LongRunningTaskResult.Cancelled)
                        {
                            _workerThread = null;
                            View.Invoke(CloseView);
                            return;
                        }
                        else if (result == LongRunningTaskResult.Error)
                        {
                            ShowError("Download failed", "Failed to download " + Game.Current.Name + " update");
                            _workerThread = null;
                            View.Invoke(CloseView);
                            return;
                        }
                        else
                        {
                            using (var gameInstall = new GameInstall(gameUpdateFile))
                            {
                                lock (_lock)
                                {
                                    Logger.Current.Write(LogInfoLevel.Info, "Installing " + Game.Current.Name + " update...");
                                    //success, now try to apply the downloaded update
                                    View.Invoke(() => View.Details = "Installing " + Game.Current.Name + " update...");
                                    _currentTask = new GameUpdater(gameInstall);
                                }
                                result = _currentTask.Start();

                                if (result == LongRunningTaskResult.Error)
                                {
                                    ShowError("Install failed", "Failed to install " + Game.Current.Name + " update");
                                }
                            }

                            //now if we're auto installing on update, update the registry/desktop icons etc..
                            if (Config.Current.AutoRegisterOnUpdate)
                            {
                                lock (_lock)
                                {
                                    Logger.Current.Write(LogInfoLevel.Info, "Registering game update...");
                                    _currentTask = new GameRegistrar(true, Game.Current);
                                }
                                result = _currentTask.Start();
                                if (result == LongRunningTaskResult.Error)
                                {
                                    ShowError("Registration failed", "Failed to register " + Game.Current.Name + " update");
                                }
                            }
                        }
                    }
                    finally
                    {
                        var file = FileSystem.Current.GetFile(gameUpdateFile);
                        if (file.Exists)
                        {
                            file.DeleteWithTimeout();
                        }
                    }
                }
            }
            catch (ThreadAbortException)
            {
            }
            catch (Exception ex)
            {
                View.Invoke(() => Program.ShowUnhandledError(ex));
            }

            _workerThread = null;
            View.Invoke(CloseView);
        }
Example #14
0
        private static void commandlineSetup(string destination, bool checkInstallation = true, bool cleanup = false, bool onlyCopy = false)
        {
            destination = destination.Replace("\"", "");
            if (!Common.IsValidLocalPath(destination) || !Directory.Exists(destination))
            {
                ExitWithError((int)Exitcode.CmdInstallFailed, "Invalid or none existing destination given");
            }

            if (onlyCopy)
            {
                File.Copy(Assembly.GetEntryAssembly().Location, Path.Combine(destination, "ScChrom.exe"), true);
                return;
            }

            if (cleanup)
            {
                cleanupInstallationDirectory(destination);
            }

            var waitTillFinished = new ManualResetEvent(false);
            var installer        = new DependencyInstaller(Dependencies, true);

            installer.DownloadCanceled += (ex) => {
                string text = "Error occured during download, stopping. Error was: " + ex.Message;
                ExitWithError((int)Exitcode.CmdInstallFailed, text);
            };
            installer.ExtractionStarted += (dependencyName) => {
                Console.WriteLine("Extracting " + dependencyName);
            };
            installer.DownloadStarted += () => {
                Console.WriteLine("Downloading next dependency");
            };
            installer.ProgressChanged += (ProgressState progress) => {
                if (progress.Progress > 0)
                {
                    Console.WriteLine(progress.Progress + "% finished");
                }
            };
            installer.ErrorOccured += (ex) => {
                string text = "Error occured during setup, stopping. Error was: " + ex.Message;
                ExitWithError((int)Exitcode.CmdInstallFailed, text);
            };
            installer.InstallationFinished += () => {
                if (checkInstallation)
                {
                    try {
                        var proc = Process.Start(Path.Combine(installer.DestinationDirectory, "ScChrom.exe"), "check");
                        if (!proc.WaitForExit(30 * 1000))
                        {
                            ExitWithError((int)Exitcode.CmdInstallFailed, "Check of the new setup ScChrom failed because of timeout of new installation");
                        }
                    } catch (Exception ex) {
                        ExitWithError((int)Exitcode.CmdInstallFailed, "Check of setup ScChrom failed: " + ex.Message);
                    }
                    Console.WriteLine("Check finished");
                }

                Console.WriteLine("Installation finished");

                waitTillFinished.Set();
            };

            installer.DestinationDirectory = destination;
            installer.DownloadDependencies();

            // Wait max half an hour (enough for DSL 1000) before closing with error
            if (!waitTillFinished.WaitOne(30 * 60 * 60))
            {
                ExitWithError((int)Exitcode.CmdInstallFailed, "Automatically canceled installation after timeout");
            }
        }