public IEnumerable <VirtualNetwork> GetValidNetworks(ICommandLineInterface cli) { if (cli == null) { throw new ArgumentNullException(nameof(cli)); } var __ValidNetworks = new List <VirtualNetwork>(); var __Accounts = cli.GetAccounts().ToList(); foreach (var __Network in this.Networks) { var __ValidationResult = this.ValidateVirtualNetworkConfiguration(__Network); if (!__ValidationResult) { this.Logger.Error($"Virtual network configuration \"{__Network.Name}\" invalid. This network will not be monitored."); } else if (__Accounts.SingleOrDefault(i => String.Equals(__Network.Name, i.Name)) == null) { this.Logger.Warn($"Account \"{__Network.Name}\" not found in VPN client service."); __ValidNetworks.Add(__Network); } else { __ValidNetworks.Add(__Network); } } return(__ValidNetworks); }
public ClientService ( ILogger <ClientService> logger, ILogger <VirtualNetworkService> networkLogger, IHostApplicationLifetime appLifetime, IOptions <GeneralOptions> generalOptions, IOptions <NetworkOptions> networkOptions, ICommandLineInterface cli, IInternetConnectionVerifier internetConnectionVerifierVerifier, IVpnConnectionVerifier vpnConnectionVerifier, IPlatform platform ) { this._Logger = logger ?? throw new ArgumentNullException(nameof(logger)); this._NetworkLogger = networkLogger ?? throw new ArgumentNullException(nameof(networkLogger)); this._AppLifetime = appLifetime ?? throw new ArgumentNullException(nameof(appLifetime)); this._GeneralOptions = generalOptions ?? throw new ArgumentNullException(nameof(generalOptions)); this._NetworkOptions = networkOptions ?? throw new ArgumentNullException(nameof(networkOptions)); this._Cli = cli ?? throw new ArgumentNullException(nameof(cli)); this._InternetConnectionVerifierVerifier = internetConnectionVerifierVerifier ?? throw new ArgumentNullException(nameof(internetConnectionVerifierVerifier)); this._VpnConnectionVerifier = vpnConnectionVerifier ?? throw new ArgumentNullException(nameof(vpnConnectionVerifier)); this._Platform = platform ?? throw new ArgumentNullException(nameof(platform)); this._ClientServiceRestarting = new Subject <Object>(); this._ClientServiceRestarted = new Subject <Object>(); this._Networks = new Dictionary <VirtualNetworkService, Int32>(); this._IsInternetConnected = null; }
public CommandsHost( IServiceProvider services, ICommandLineInterface cli, CommandDelegate app) { _services = services ?? throw new ArgumentNullException(nameof(services)); _cli = cli ?? throw new ArgumentNullException(nameof(cli)); _app = app ?? throw new ArgumentNullException(nameof(app)); _isDisposed = false; }
public CommandLineParser(ICommandLineInterface commandLineInterface) { // Build the parser with a handler, arguments, options, and middleware. // Parameters to the handler are matched by name to the arguments and options below. // https://github.com/dotnet/command-line-api/wiki/How-To#Pass-parameters-to-a-method var rootCommand = new RootCommand() { Name = "mgcb-editor", Handler = CommandHandler.Create <InvocationContext, string>((context, project) => { runAction = () => commandLineInterface.Run(context, project); }) }; var projectArgument = new Argument <string>("project") { Arity = ArgumentArity.ZeroOrOne, Description = "The path to a .mgcb file." }; var registerOption = new Option(new string[] { "/r", "-r", "/register", "--register" }) { Argument = new Argument <bool>(), Description = "Register MGCB Editor as the default application for .mgcb files for the current user, replacing any previous registration." }; var unregisterOption = new Option(new string[] { "/u", "-u", "/unregister", "--unregister" }) { Argument = new Argument <bool>(), Description = "Unregister MGCB Editor as the default application for .mgcb files for the current user." }; var versionOption = new Option(new string[] { "/v", "-v", "/version", "--version" }) { Argument = new Argument <bool>(), Description = "Show version information." }; parser = new CommandLineBuilder(rootCommand) .AddArgument(projectArgument) .AddOption(registerOption) .AddOption(unregisterOption) .AddOption(versionOption) .UseMiddleware(CreateShortCircuitMiddleware(registerOption, commandLineInterface.Register)) .UseMiddleware(CreateShortCircuitMiddleware(unregisterOption, commandLineInterface.Unregister)) .UseMiddleware(CreateShortCircuitMiddleware(versionOption, ShowVersion)) .UseDefaults() .Build(); }
public VirtualNetworkService ( ILogger <VirtualNetworkService> logger, ICommandLineInterface cli, IVpnConnectionVerifier vpnConnectionVerifier, IPlatform platform, Subject <Object> clientServiceRestarting, Subject <Object> clientServiceRestarted, VirtualNetwork network ) { if (clientServiceRestarting == null) { throw new ArgumentNullException(nameof(clientServiceRestarting)); } if (clientServiceRestarted == null) { throw new ArgumentNullException(nameof(clientServiceRestarted)); } this._Logger = logger ?? throw new ArgumentNullException(nameof(logger)); this._Cli = cli ?? throw new ArgumentNullException(nameof(cli)); this._VpnConnectionVerifier = vpnConnectionVerifier ?? throw new ArgumentNullException(nameof(vpnConnectionVerifier)); this._Platform = platform ?? throw new ArgumentNullException(nameof(platform)); this.Configuration = network ?? throw new ArgumentNullException(nameof(network)); this._IsDisposed = new Subject <Object>(); var __IsInitialized = new Subject <Object>(); clientServiceRestarting .TakeUntil(this._IsDisposed) .SkipUntil(__IsInitialized) .Subscribe(this.OnClientServiceRestarting); clientServiceRestarted .TakeUntil(this._IsDisposed) .SkipUntil(__IsInitialized) .Subscribe(this.OnClientServiceRestarted); this._Account = new BehaviorSubject <Account>(null); this._Account .TakeUntil(this._IsDisposed) .SkipUntil(__IsInitialized) .DistinctUntilChanged() .Subscribe(this.OnAccountFoundChanged); this._Device = new BehaviorSubject <Device>(null); this._Device .SkipUntil(__IsInitialized) .TakeUntil(this._IsDisposed) .DistinctUntilChanged() .Subscribe(this.OnDeviceFoundChanged); // this._Interface = new BehaviorSubject<NetworkInterface>(null); // this._Interface // // .TakeUntil(this._IsDisposed) // .SkipUntil(__IsInitialized) // .DistinctUntilChanged() // .Subscribe(this.OnInterfaceFoundChanged); this._InterfaceName = new BehaviorSubject <String>(null); this._InterfaceName .TakeUntil(this._IsDisposed) .SkipUntil(__IsInitialized) .DistinctUntilChanged() .Subscribe(this.OnInterfaceFoundChanged); this._IPv4AddressAssigned = new BehaviorSubject <Boolean?>(null); this._IPv4AddressAssigned .TakeUntil(this._IsDisposed) .SkipUntil(__IsInitialized) .NotNull() .DistinctUntilChanged() .Subscribe(this.OnIPv4AddressAssignedChanged); this._IPv6AddressAssigned = new BehaviorSubject <Boolean?>(null); this._IPv6AddressAssigned .TakeUntil(this._IsDisposed) .SkipUntil(__IsInitialized) .NotNull() .DistinctUntilChanged() .Subscribe(this.OnIPv6AddressAssignedChanged); this._IPv4RoutesAssigned = new BehaviorSubject <Boolean?>(null); this._IPv4RoutesAssigned .TakeUntil(this._IsDisposed) .SkipUntil(__IsInitialized) .NotNull() .DistinctUntilChanged() .Subscribe(this.OnIPv4RoutesAppliedChanged); this._IPv6RoutesAssigned = new BehaviorSubject <Boolean?>(null); this._IPv6RoutesAssigned .TakeUntil(this._IsDisposed) .SkipUntil(__IsInitialized) .NotNull() .DistinctUntilChanged() .Subscribe(this.OnIPv6RoutesAppliedChanged); this._ConfigurationState = new BehaviorSubject <ConfigurationState?>(null); this._ConfigurationState .TakeUntil(this._IsDisposed) .SkipUntil(__IsInitialized) .NotNull() .DistinctUntilChanged() .Subscribe(this.OnConfigurationStateChanged); this._ConnectionState = new BehaviorSubject <ConnectionState?>(null); this._ConnectionState .TakeUntil(this._IsDisposed) .SkipUntil(__IsInitialized) .NotNull() .DistinctUntilChanged() .Subscribe(this.OnConnectionStateChanged); this._ReachableState = new BehaviorSubject <ReachableState?>(null); this._ReachableState .TakeUntil(this._IsDisposed) .NotNull() .DistinctUntilChanged() .Subscribe(this.OnReachableStateChanged); this._ConnectionVerificationResult = new BehaviorSubject <ConnectionVerificationResult>(null); this._ConnectionVerificationResult .TakeUntil(this._IsDisposed) .NotNull() .DistinctUntilChanged() .Subscribe(this.OnConnectionVerificationResultChanged); __IsInitialized.OnNext(null); }
public Account(ICommandLineInterface cli, Dictionary <String, String> data) : base(cli, data) { }
public Device(ICommandLineInterface cli, Dictionary <String, String> data) : base(cli, data) { }
protected QueryResult(ICommandLineInterface cli, Dictionary <String, String> data) { this._Cli = cli ?? throw new ArgumentNullException(nameof(cli)); this._Data = data ?? throw new ArgumentNullException(nameof(data)); }
public void Quit(ICommandLineInterface cli) { // Do not await it because the app will wait // until the command execution is over. cli.StopAsync(); }
/// <summary> /// Initialisiert eine neue Instanz der <see cref="T:System.Object"/>-Klasse. /// </summary> public App(IConsole console, IFileSystem file, ICommandLineInterface cli) { this.console = console; this.file = file; this.cli = cli; }
public ConfigCommand(ICommandLineInterface commandLineInterface) { this.commandLineInterface = commandLineInterface; }