コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WebProcessMonitor"/> class.
 /// </summary>
 /// <param name="process">The process.</param>
 public WebProcessMonitor(ConsoleHost.IProcessHost process)
     : base(process)
 {
     process.RegisterOutputConsumer(this.outputStream);
     this.hostWrapper = new WebProcessMonitor.ProcessHostWrapper(process);
     this.host = WebProcessMonitor.ProcessMonitorHost.Create();
     this.hostSponser.Register(this.host);
 }
コード例 #2
0
        private void Select_Mintty_clicked(object sender, RoutedEventArgs e)
        {
            var dialog = new OpenFileDialog();

            dialog.FileName = "mintty.exe";
            if (dialog.ShowDialog() == true)
            {
                if (dialog.SafeFileName == "mintty.exe")
                {
                    Config.Instance.MinttyPath = dialog.FileName;
                    ConsoleHost.LoadMinttyHost();
                }
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: lacknc/projectalpha
 static void Main(string[] args)
 {
     try
     {
         ConsoleHost host = new ConsoleHost(new ServiceHost());
         host.Run();
         Environment.Exit(0);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Hosted service exception: {0}", ex.Message);
         Environment.Exit(1);
     }
 }
コード例 #4
0
        async Task PreviewAndExecuteUpdateActionsforAllPackages(NuGetProject project)
        {
            var packageManager = ConsoleHost.CreatePackageManager();
            var context        = CreateResolutionContext();
            var actions        = await packageManager.PreviewUpdatePackagesAsync(
                project,
                context,
                this,
                PrimarySourceRepositories,
                PrimarySourceRepositories,
                ConsoleHost.Token);

            await ExecuteActions(project, actions, packageManager, context.SourceCacheContext);
        }
コード例 #5
0
        public static NAutowired.Core.IConsoleHost BuildConsoleHost(string[] args)
        {
            var config = LoadConfig();

            return(ConsoleHost.CreateDefaultBuilder(services =>
            {
                services.AddTransient(typeof(ICommandLineArguments),
                                      serviceProvider => new CommandLineArguments(args));
                services.AddTransient(typeof(INumeralSystem),
                                      serviceProvider => new NumeralSystem(config.NumeralSystemBase));
            }, new List <string> {
                "LcdNumbers"
            }, new string[0])
                   .Build());
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: pabloordonez/PiDockerCore
        static void Main(string[] args)
        {
            var host = ConsoleHost.Create();

            host.ParseArguments <ApplicationArguments>(args)
            .SetVersion("1.0", "1.0.0");

            host.UseStartup <Startup>()
            .Build();

            if (host.HostingEnvironment.IsDevelopment())
            {
                Console.ReadKey();
            }
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: hanin/data-pipeline
 private static void Main(string[] args)
 {
     ConsoleHost.WithOptions(
         new Dictionary <string, Func <CancellationToken, Task> >
     {
         {
             "Provision Resources",
             ProvisionResourcesAsync
         },
         {
             "Run Dispatching Processor",
             RunAsync
         }
     });
 }
コード例 #8
0
        public static int Start(InitialSessionState initialSessionState, string?bannerText, string?helpText, string[] args)
        {
            if (initialSessionState == null)
            {
                throw PSTraceSource.NewArgumentNullException(nameof(initialSessionState));
            }

            if (args == null)
            {
                throw PSTraceSource.NewArgumentNullException(nameof(args));
            }

            ConsoleHost.ParseCommandLine(args);
            ConsoleHost.DefaultInitialSessionState = initialSessionState;

            return(ConsoleHost.Start(bannerText, helpText));
        }
コード例 #9
0
        protected async Task InstallPackageByIdentityAsync(
            NuGetProject project,
            PackageIdentity identity,
            ResolutionContext resolutionContext,
            INuGetProjectContext projectContext,
            bool isPreview)
        {
            try {
                var packageManager = ConsoleHost.CreatePackageManager();

                var actions = await packageManager.PreviewInstallPackageAsync(
                    project,
                    identity,
                    resolutionContext,
                    projectContext,
                    PrimarySourceRepositories,
                    null,
                    ConsoleHost.Token);

                if (isPreview)
                {
                    PreviewNuGetPackageActions(actions);
                }
                else
                {
                    NuGetPackageManager.SetDirectInstall(identity, projectContext);
                    await packageManager.ExecuteNuGetProjectActionsAsync(
                        project,
                        actions,
                        this,
                        resolutionContext.SourceCacheContext,
                        ConsoleHost.Token);

                    NuGetPackageManager.ClearDirectInstall(projectContext);
                }
            } catch (InvalidOperationException ex) {
                if (ex.InnerException is PackageAlreadyInstalledException)
                {
                    Log(ProjectManagement.MessageLevel.Info, ex.Message);
                }
                else
                {
                    throw ex;
                }
            }
        }
コード例 #10
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;

            _consoleApplication = ConsoleHost
                                  .CreateDefaultBuilder(args, new ConsoleHostConfigurationOptions
            {
                ConsulConfigurationOptions = new ConsulConfigurationOptions
                {
                    AppsettingsFileName = "appsettings-async.json"
                }
            })
                                  .Build() as IConsoleApplication;

            Console.WriteLine(JsonConvert.SerializeObject(_consoleApplication.Configuration));

            Console.ReadKey();
        }
コード例 #11
0
        protected void Preprocess()
        {
            ThrowErrorIfProjectNotOpen();
            UpdateActiveSourceRepository(Source);
            project = ConsoleHost.GetNuGetProject(ProjectName);
            DetermineFileConflictAction();

            ParseUserInputForId();
            ParseUserInputForVersion();

            // The following update to ActiveSourceRepository may get overwritten if the 'Id' was just a path to a nupkg
            if (readFromDirectPackagePath)
            {
                UpdateActiveSourceRepository(Source);
            }

            ActionType = NuGetActionType.Install;
        }
コード例 #12
0
        async Task PreviewAndExecuteUpdateActionsforSinglePackage(NuGetProject project)
        {
            ConsoleHostNuGetPackageManager packageManager = null;

            var installedPackage = (await project.GetInstalledPackagesAsync(ConsoleHost.Token))
                                   .FirstOrDefault(p => string.Equals(p.PackageIdentity.Id, Id, StringComparison.OrdinalIgnoreCase));

            if (installedPackage != null)
            {
                // set _installed to true, if package to update is installed.
                isPackageInstalled = true;

                packageManager = ConsoleHost.CreatePackageManager();
                var actions = Enumerable.Empty <NuGetProjectAction> ();

                var resolutionContext = CreateResolutionContext();
                // If -Version switch is specified
                if (!string.IsNullOrEmpty(Version))
                {
                    actions = await packageManager.PreviewUpdatePackagesAsync(
                        new PackageIdentity (installedPackage.PackageIdentity.Id, PowerShellCmdletsUtility.GetNuGetVersionFromString(Version)),
                        project,
                        resolutionContext,
                        this,
                        PrimarySourceRepositories,
                        EnabledSourceRepositories,
                        ConsoleHost.Token);
                }
                else
                {
                    actions = await packageManager.PreviewUpdatePackagesAsync(
                        installedPackage.PackageIdentity.Id,
                        project,
                        resolutionContext,
                        this,
                        PrimarySourceRepositories,
                        EnabledSourceRepositories,
                        ConsoleHost.Token);
                }

                await ExecuteActions(project, actions, packageManager, resolutionContext.SourceCacheContext);
            }
        }
コード例 #13
0
        protected async Task UninstallPackageByIdAsync(
            NuGetProject project,
            string packageId,
            UninstallationContext uninstallContext,
            INuGetProjectContext projectContext,
            bool isPreview)
        {
            ConsoleHostNuGetPackageManager   packageManager = ConsoleHost.CreatePackageManager();
            IEnumerable <NuGetProjectAction> actions        = await packageManager.PreviewUninstallPackageAsync(project, packageId, uninstallContext, projectContext, ConsoleHost.Token);

            if (isPreview)
            {
                PreviewNuGetPackageActions(actions);
            }
            else
            {
                await packageManager.ExecuteNuGetProjectActionsAsync(project, actions, projectContext, ConsoleHost.Token);
            }
        }
コード例 #14
0
        public static async Task <int> Run <T>(string[] args, T commandLineBinding) where T : ICommandLineBinding
        {
            var initialisationInformation = new InitialisationInformation();

            initialisationInformation.AddMessage(MessageType.Information, $"Received command line {string.Join(" ", args.Select(x => $"[{x}]"))}");
            var consoleHost = new ConsoleHost();

            var parserType        = typeof(CommandLineParser <>).MakeGenericType(commandLineBinding.CommandLineType);
            var commandLineParser = (ICommandLineParser)Activator.CreateInstance(parserType);

            var parseResult = commandLineParser.Parse(args, initialisationInformation);

            switch (parseResult.ParseResult)
            {
            case ParseResult.Failed:
                consoleHost.ReportInitialisation(initialisationInformation);
                return(ReturnCodes.CommandLineParsingFailed);

            case ParseResult.SuccessfulAndExit:
                consoleHost.ReportInitialisation(initialisationInformation);
                return(ReturnCodes.Success);

            default:
                var          applicationBootstrapper = commandLineBinding.CreateBootstrapper(parseResult.CommandLine);
                IApplication application             = null;

                try
                {
                    application = applicationBootstrapper.Bootstrap();
                }
                catch (Exception ex)
                {
                    initialisationInformation.AddMessage(MessageType.Error, $"Failed to bootstrap{Environment.NewLine}{ex}");
                    consoleHost.ReportInitialisation(initialisationInformation);
                    return(ReturnCodes.BoostrapFailed);
                }

                var returnCode = await consoleHost.Run(application, initialisationInformation);

                return((int)returnCode);
            }
        }
コード例 #15
0
 BeginProcessing()
 {
     try
     {
         string outFilename = Host.UI.StopTranscribing();
         if (outFilename != null)
         {
             PSObject outputObject = new PSObject(
                 StringUtil.Format(TranscriptStrings.TranscriptionStopped, outFilename));
             outputObject.Properties.Add(new PSNoteProperty("Path", outFilename));
             WriteObject(outputObject);
         }
     }
     catch (Exception e)
     {
         ConsoleHost.CheckForSevereException(e);
         throw PSTraceSource.NewInvalidOperationException(
                   e, TranscriptStrings.ErrorStoppingTranscript, e.Message);
     }
 }
コード例 #16
0
        /// <summary>
        /// Create a package repository from the source by trying to resolve relative paths.
        /// </summary>
        protected SourceRepository CreateRepositoryFromSource(string source)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            var packageSource = new NuGet.Configuration.PackageSource(source);
            var repository    = ConsoleHost.CreateRepository(packageSource);
            var resource      = repository.GetResource <PackageSearchResource> ();

            // resource can be null here for relative path package source.
            if (resource == null)
            {
                Uri uri;
                // if it's not an absolute path, treat it as relative path
                if (Uri.TryCreate(source, UriKind.Relative, out uri))
                {
                    throw new NotImplementedException();
                    //string outputPath;
                    //bool? exists;
                    //string errorMessage;
                    //// translate relative path to absolute path
                    //if (TryTranslatePSPath (source, out outputPath, out exists, out errorMessage) && exists == true) {
                    //	source = outputPath;
                    //	packageSource = new Configuration.PackageSource (outputPath);
                    //}
                }
            }

            var sourceRepo = ConsoleHost.CreateRepository(packageSource);
            // Right now if packageSource is invalid, CreateRepository will not throw. Instead, resource returned is null.
            var newResource = repository.GetResource <PackageSearchResource> ();

            if (newResource == null)
            {
                // Try to create Uri again to throw UriFormat exception for invalid source input.
                new Uri(source);
            }
            return(sourceRepo);
        }
コード例 #17
0
ファイル: Program.cs プロジェクト: zebemce/VideoGate
 private static void RunAsDaemon(string[] args)
 {
     logger.Info("Running as daemon");
     try
     {
         Start(null, new StringsEventArgs(args));
         if (CheckConsole())
         {
             logger.Info("Application running. Press Ctrl+C to shut down.");
         }
         ConsoleHost.WaitForShutdownAsync().GetAwaiter().GetResult();
     }
     catch (Exception ex)
     {
         ShowUnhandledException(ex);
     }
     finally
     {
         Stop(null, EventArgs.Empty);
     }
 }
コード例 #18
0
        List <NuGetProject> GetNuGetProjects()
        {
            if (HasSelectedProjectName())
            {
                return new List <NuGetProject> {
                           ConsoleHost.GetNuGetProject(ProjectName)
                }
            }
            ;

            return(ConsoleHost.GetNuGetProjects().ToList());
        }

        bool HasSelectedProjectName()
        {
            return(ProjectName != null);
        }

        void WriteInstalledPackages()
        {
            CheckSolutionIsOpen();

            var packagesToDisplay = GetInstalledPackagesAsync(projects, Filter, Skip, First, ConsoleHost.Token);

            WriteInstalledPackages(packagesToDisplay.Result);
        }

        void WriteInstalledPackages(Dictionary <NuGetProject, IEnumerable <NuGet.Packaging.PackageReference> > packages)
        {
            List <PowerShellInstalledPackage> view = PowerShellInstalledPackage.GetPowerShellPackageView(packages, ConsoleHost.SolutionManager, ConsoleHost.Settings);

            if (view.Any())
            {
                WritePackagesToOutputPipeline(view);
            }
            else
            {
                Log(MessageLevel.Info, GettextCatalog.GetString("No packages installed."));
            }
        }
コード例 #19
0
        protected override void BeginProcessing()
        {
            InternalHost host = base.Host as InternalHost;

            if (host != null)
            {
                ConsoleHost externalHost = host.ExternalHost as ConsoleHost;
                if (externalHost != null)
                {
                    if (!externalHost.IsTranscribing)
                    {
                        base.WriteObject(TranscriptStrings.TranscriptionNotInProgress);
                    }
                    try
                    {
                        string str = externalHost.StopTranscribing();
                        base.WriteObject(StringUtil.Format(TranscriptStrings.TranscriptionStopped, str));
                    }
                    catch (Exception exception1)
                    {
                        Exception exception = exception1;
                        ConsoleHost.CheckForSevereException(exception);
                        object[] message = new object[1];
                        message[0] = exception.Message;
                        throw PSTraceSource.NewInvalidOperationException(exception, "TranscriptStrings", "ErrorStoppingTranscript", message);
                    }
                    return;
                }
                else
                {
                    throw PSTraceSource.NewNotSupportedException("TranscriptStrings", "HostDoesNotSupportTranscript", new object[0]);
                }
            }
            else
            {
                throw PSTraceSource.NewNotSupportedException("TranscriptStrings", "HostDoesNotSupportTranscript", new object[0]);
            }
        }
コード例 #20
0
        private static async Task Main(string[] args)
        {
            // キャッシュ
            WeatherModel.CacheWeatherIcons(General.WeatherIconsPath);
            // 設定読み込み
            Settings = SettingLoader.Load <SettingModel>();

            if (string.IsNullOrWhiteSpace(Settings?.OpenWeatherMap.ApiKey))
            {
                Log.WriteLogLine("OpenWeatherMap へ接続するための API Key が見つかりません", Log.LogType.Error);
                await ConsoleHost.WaitAsync();

                return;
            }

            SetTimer();

            Connect();

            await ConsoleHost.WaitAsync();

            Disconnect();
        }
コード例 #21
0
        static void Main(string[] args)
        {
            var options = new Dictionary <string, Func <CancellationToken, Task> >()
            {
                { "Add a movie", AddMovieAsync },

                { "Update a movie", UpdateMovieAsync },

                { "Delete a movie", DeleteMovieAsync },

                { "Add a person", AddPersonAsync },

                { "Update a person", UpdatePersonAsync },

                { "Delete a person", DeletePersonAsync },

                { "List movies", ListMoviesAsync },

                { "List persons", ListPersonsAsync }
            };

            ConsoleHost.RunWithOptionsAsync(options).Wait();
        }
コード例 #22
0
ファイル: Program.cs プロジェクト: neuronesb/NSwag
        static void Main(string[] args)
        {
            var host = new ConsoleHost();

            host.WriteMessage("NSwag command line: v" + typeof(SwaggerInfo).Assembly.GetName().Version + "\n");
            host.WriteMessage("Visit http://NSwag.org for more information.\n");
            host.WriteMessage("Execute the 'help' command to show a list of all the available commands.\n");

            try
            {
                var processor = new CommandLineProcessor(host);

                processor.RegisterCommand <WebApiToSwaggerCommand>("webapi2swagger");

                processor.RegisterCommand <JsonSchemaToCSharpCommand>("jsonschema2csclient");
                processor.RegisterCommand <JsonSchemaToTypeScriptCommand>("jsonschema2tsclient");

                processor.RegisterCommand <SwaggerToCSharpClientCommand>("swagger2csclient");
                processor.RegisterCommand <SwaggerToCSharpWebApiControllerCommand>("swagger2cscontroller");
                processor.RegisterCommand <SwaggerToTypeScriptCommand>("swagger2tsclient");

                processor.Process(args);
            }
            catch (Exception exception)
            {
                var savedForegroundColor = Console.ForegroundColor;
                Console.ForegroundColor = ConsoleColor.Red;
                host.WriteMessage(exception.ToString());
                Console.ForegroundColor = savedForegroundColor;
            }

            if (Debugger.IsAttached)
            {
                Console.WriteLine("Press <any> key to exit...");
                Console.ReadKey();
            }
        }
コード例 #23
0
        IPackageRepository CreatePackageRepositoryForActivePackageSource()
        {
            PackageSource packageSource = ConsoleHost.GetActivePackageSource(Source);

            return(registeredPackageRepositories.CreateRepository(packageSource));
        }
コード例 #24
0
 IPackageManagementProject GetProject()
 {
     return(ConsoleHost.GetProject(Source, ProjectName));
 }
コード例 #25
0
        IPackageManagementProject GetSelectedProject(IPackageRepository repository)
        {
            string projectName = GetSelectedProjectName();

            return(ConsoleHost.GetProject(repository, projectName));
        }
コード例 #26
0
 IConsoleHostFileConflictResolver CreateFileConflictResolver()
 {
     return(ConsoleHost.CreateFileConflictResolver(FileConflictAction));
 }
コード例 #27
0
        IPackageManagementProject GetProject()
        {
            string source = null;

            return(ConsoleHost.GetProject(source, ProjectName));
        }
コード例 #28
0
 /// <summary>
 /// Starts the specified output stream.
 /// </summary>
 /// <param name="outputStream">The output stream.</param>
 /// <param name="processHost">The process host.</param>
 public void Start(MemoryMessageStream outputStream, ConsoleHost.IProcessHost processHost)
 {
     this.outputStream = outputStream;
     this.processHost = processHost;
     AppDomain.CurrentDomain.SetData(".output", this.outputStream);
     AppDomain.CurrentDomain.SetData(".processHost", this.processHost);
     this.sponsor.Register((MarshalByRefObject)this.processHost);
     this.sponsor.Register(this.outputStream);
     this.webServer.Start();
 }
コード例 #29
0
        void UninstallPackage()
        {
            NuGetProject project = ConsoleHost.GetNuGetProject(ProjectName);

            UninstallPackageByIdAsync(project, Id, CreateUninstallContext(), this, WhatIf.IsPresent).Wait();
        }
コード例 #30
0
        IPackageRepository GetActivePackageRepository()
        {
            PackageSource packageSource = ConsoleHost.GetActivePackageSource(Source);

            return(ConsoleHost.GetPackageRepository(packageSource));
        }
コード例 #31
0
 protected IDisposable CreateEventsMonitor()
 {
     return(ConsoleHost.CreateEventsMonitor(this));
 }
コード例 #32
0
        IPackageManagementProject GetSelectedProject()
        {
            string projectName = GetSelectedProjectName();

            return(ConsoleHost.GetProject(Source, projectName));
        }
コード例 #33
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProcessHostWrapper"/> class.
 /// </summary>
 /// <param name="inner">The inner interface.</param>
 public ProcessHostWrapper(ConsoleHost.IProcessHost inner)
 {
     this.inner = inner;
 }