Beispiel #1
0
        public TimerHandler( IConfigHandler config )
        {
            this.config = config;

            this.TimedEvents = new ObservableCollection<TimedEvent>();

            this.clock.Tick += ( se, ea ) =>
            {
                foreach ( var t in this.TimedEvents.ToList() )
                {
                    t.NotifyOfPropertyChange( "TimeRemaining" );

                    if ( t.TimeRemaining.Ticks == 0 )
                    {
                        if ( this.TimedEventCompleted != null )
                        {
                            this.TimedEventCompleted( t, null );
                        }

                        this.TimedEvents.Remove( t );
                    }
                }
            };
            this.clock.Start();
        }
Beispiel #2
0
        public LoginHandler(ILogger logger)
        {
            _logger = logger;
            var custome = FastTunnelGlobal.GetCustomHandler <IConfigHandler>();

            _configHandler = custome == null ? new ConfigHandler() : custome;
        }
 public DynDns53ConsoleClient(IConfigHandler configHandler, IAmazonRoute53 route53Client, IHeartbeatService heartbeatService, ILog logger)
 {
     this.configHandler    = configHandler;
     this.route53Client    = route53Client;
     this.heartbeatService = heartbeatService;
     this.logger           = logger;
 }
Beispiel #4
0
        internal void CreateLinks(IConsole console, IConfigHandler configHandler, IFileSystem fileSystem, IPathResolver pathResolver, IConfig config, string sourceDirectory, string targetDirectory)
        {
            if (!linkDirectories)
            {
                foreach (string file in fileSystem.Directory.GetFiles(pathResolver.GetAbsoluteResolvedPath(sourceDirectory, config.Variables)))
                {
                    TryCreateLink(console, configHandler, fileSystem, pathResolver, config, file, targetDirectory, true);
                }

                // Recursive - Will create links for all files in sub-dirs as well
                if (includeSubdirectories)
                {
                    foreach (string directory in fileSystem.Directory.GetDirectories(pathResolver.GetAbsoluteResolvedPath(sourceDirectory, config.Variables)))
                    {
                        CreateLinks(console, configHandler, fileSystem, pathResolver, config, directory, fileSystem.Path.Combine(targetDirectory, fileSystem.Path.GetFileName(directory)));
                    }
                }
            }
            else
            {
                foreach (string directory in fileSystem.Directory.GetDirectories(pathResolver.GetAbsoluteResolvedPath(sourceDirectory, config.Variables)))
                {
                    TryCreateLink(console, configHandler, fileSystem, pathResolver, config, directory, targetDirectory, false);
                }
            }
        }
Beispiel #5
0
        public void Execute(IConsole console, IConfigHandler configHandler, IFileSystem fileSystem)
        {
            if (!configHandler.DoesConfigExist(path))
            {
                console.WriteLine($"Config '{ path }' does not exist. Type 'help config' in order to see how you create a config file.", IConsole.ContentType.Negative);
                return;
            }

            IConfig  config           = configHandler.LoadConfig(path);
            Variable existingVariable = config.Variables.FirstOrDefault(variable => variable.name.Equals(name, StringComparison.OrdinalIgnoreCase));

            if (existingVariable == null)
            {
                config.Variables.Add(new Variable(name, value));
                console.WriteLine($"Added new variable '{ name }' with value '{ value }'");

                configHandler.SaveConfig(config, path);
            }
            else
            {
                if (!force)
                {
                    console.WriteLine($"A variable with the name '{ name }' already exists", IConsole.ContentType.Negative);
                }
                else
                {
                    existingVariable.value = value;
                    console.WriteLine($"Replaced existing variable value for '{ name }' with '{ value }'");

                    configHandler.SaveConfig(config, path);
                }
            }
        }
Beispiel #6
0
        private void InitConfig()
        {
            AddLog("Loading configuration values...");

            _configHandler = new AppConfigHandler();
            _config        = _configHandler.GetConfig();
            _ipChecker     = _config.IPChecker;

            var _amazonClient = new AmazonRoute53Client(_config.Route53AccessKey, _config.Route53SecretKey, RegionEndpoint.USEast1);

            _dnsUpdater = new DnsUpdater(_amazonClient);

            AddLog($"Found {_config.DomainList.Count} domain(s)");
            foreach (HostedDomainInfo domainInfo in _config.DomainList)
            {
                AddLog($"{domainInfo.DomainName}");
            }

            if (_timer != null)
            {
                // Stop to avoid multiple timer_Tick invocations
                _timer.Stop();
            }

            int interval = _config.UpdateInterval;

            _timer          = new System.Windows.Threading.DispatcherTimer();
            _timer.Tick    += timer_Tick;
            _timer.Interval = new TimeSpan(0, 0, interval);
            _timer.Start();

            AddLog($"Time set to update domains every {interval} seconds");

            SetAutoStart();
        }
Beispiel #7
0
 public DnsUpdaterTestPad(IConfigHandler configHandler, 
     IIpChecker ipchecker,
     IAmazonRoute53 amazonClient)
 {
     _configHandler = configHandler;
     _ipChecker = ipchecker;
     _amazonClient = amazonClient;
 }
Beispiel #8
0
 public UeditorService(UploadDBContext dbContext, INotSupportedHandler NotSupportedHandler, IConfigHandler configHandler, IUploadHandler uploadHandler, IEditorConfig editorConfig, IListFileHandler listFileHandler, ICrawlerHandler crawlerHandler)
 {
     this._notSupportedHandler = NotSupportedHandler;
     this._configHandler       = configHandler;
     this._uploadHandler       = uploadHandler;
     this._editorConfig        = editorConfig;
     this._listFileHandler     = listFileHandler;
     this._crawlerHandler      = crawlerHandler;
 }
Beispiel #9
0
        public HueService(IConfigHandler configHandler)
        {
            this.configHandler = configHandler;
            config             = configHandler.LoadFromFile();
            baseUrl            = config.HueConfig.BridgeUrl;
            client             = new RestClient(baseUrl);

            TryLoadUser();
        }
        public OAuthWindowView(IStreamingService streamingService, IConfigHandler configHandler)
        {
            InitializeComponent();
            this.streamingService = streamingService ?? throw new ArgumentNullException(nameof(streamingService));
            this.configHandler    = configHandler ?? throw new ArgumentNullException(nameof(configHandler));

            OAuthWebBrowser.Source              = new Uri(streamingService.OAuthUrl);
            OAuthWebBrowser.NavigationStarting += OAuthWebBrowser_NavigationStarting;
        }
 public HttpStreamingConfigListener(string bucketName, ClusterOptions clusterOptions, HttpClient httpClient,
                                    IConfigHandler configHandler, ILogger <HttpStreamingConfigListener> logger)
 {
     _bucketName     = bucketName ?? throw new ArgumentNullException(nameof(bucketName));
     _clusterOptions = clusterOptions ?? throw new ArgumentNullException(nameof(clusterOptions));
     _httpClient     = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
     _configHandler  = configHandler ?? throw new ArgumentNullException(nameof(configHandler));
     _logger         = logger ?? throw new ArgumentNullException(nameof(logger));
 }
        internal void Execute(IConsole console, IConfigHandler configHandler, IConfig defaultConfig, IPathResolver pathResolver)
        {
            if (create)
            {
                if (configHandler.DoesConfigExist(path))
                {
                    console.WriteLine("Config already exists!", IConsole.ContentType.Negative);
                }
                else
                {
                    console.WriteLine("Creating config '{0}'", path);

                    configHandler.SaveConfig(defaultConfig, path);
                }
            }
            else if (delete)
            {
                if (configHandler.DoesConfigExist(path))
                {
                    console.WriteLine("Deleting config '{0}'", path);
                    configHandler.DeleteConfig(path);
                }
                else
                {
                    console.WriteLine($"Config '{path}' does not exist!", IConsole.ContentType.Negative);
                }
            }
            else
            {
                if (configHandler.DoesConfigExist(path))
                {
                    IConfig config = configHandler.LoadConfig(path);

                    console.WriteLine();
                    console.WriteLine("### Metadata info ###", IConsole.ContentType.Header);
                    console.WriteLine($"Path: {path}");
                    console.WriteLine($"Full path: {pathResolver.GetAbsoluteResolvedPath(path, config.Variables)}");
                    console.WriteLine($"Version: {config.Version}");
                    console.WriteLine();

                    console.WriteLine("### Variable info ###", IConsole.ContentType.Header);
                    console.WriteLine("Total variables: " + config.Variables.Count);
                    console.WriteLine();

                    console.WriteLine("### Link info ###", IConsole.ContentType.Header);
                    console.WriteLine("Total links: " + config.LinkList.Count);
                    console.WriteLine("Junction links: " + config.LinkList.Count(l => l.linkType == ConfigLink.LinkType.Junction));
                    console.WriteLine("Symbolic links: " + config.LinkList.Count(l => l.linkType == ConfigLink.LinkType.Symbolic));
                    console.WriteLine("Hard links: " + config.LinkList.Count(l => l.linkType == ConfigLink.LinkType.Hard));
                }
                else
                {
                    console.WriteLine("Config does not exist. You can create one with the --create option.", IConsole.ContentType.Negative);
                }
            }
        }
 public HttpStreamingConfigListener(IBucket bucket, ClusterOptions clusterOptions, ICouchbaseHttpClientFactory httpClientFactory,
                                    IConfigHandler configHandler, ILogger <HttpStreamingConfigListener> logger)
 {
     _bucket            = bucket ?? throw new ArgumentNullException(nameof(bucket));
     _streamingUriPath  = "/pools/default/bs/" + _bucket.Name;
     _clusterOptions    = clusterOptions ?? throw new ArgumentNullException(nameof(clusterOptions));
     _httpClientFactory = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory));
     _configHandler     = configHandler ?? throw new ArgumentNullException(nameof(configHandler));
     _logger            = logger ?? throw new ArgumentNullException(nameof(logger));
 }
 public CommandExecutor(IConsole console, IConfigHandler configHandler, IFileSystem fileSystem, IConfig defaultConfig, IArgumentParser argumentHandler, ILinker linker, IPathResolver pathResolver)
 {
     this.console         = console;
     this.configHandler   = configHandler;
     this.fileSystem      = fileSystem;
     this.defaultConfig   = defaultConfig;
     this.argumentHandler = argumentHandler;
     this.linker          = linker;
     this.pathResolver    = pathResolver;
 }
Beispiel #15
0
        public TwitchService(IConfigHandler configHandler, AppConfiguration appConfiguration)
        {
            var config = configHandler.Config;

            clientId = config.TwitchClientId;
            baseUrl  = appConfiguration.TwitchApiUrl;

            OAuthUrl = baseUrl + $@"kraken/oauth2/authorize?client_id={clientId}&redirect_uri=http://localhost&response_type=token+id_token&scope=user:read:email+chat:read openid";

            client = new RestClient(baseUrl);
        }
Beispiel #16
0
        internal void Execute(IConsole console, IConfigHandler configHandler, IFileSystem fileSystem, IPathResolver pathResolver)
        {
            if (!configHandler.DoesConfigExist(path))
            {
                console.WriteLine($"Config '{ path }' does not exist. Type 'help config' in order to see how you create a config file.", IConsole.ContentType.Negative);
                return;
            }

            IConfig config = configHandler.LoadConfig(path);

            CreateLinks(console, configHandler, fileSystem, pathResolver, config, sourceDirectoryPath, targetDirectoryPath);
        }
Beispiel #17
0
        public ClusterContext(ICluster cluster, CancellationTokenSource tokenSource, ClusterOptions options)
        {
            Cluster        = cluster;
            ClusterOptions = options;
            _tokenSource   = tokenSource;

            // Register this instance of ClusterContext
            options.AddClusterService(this);

            ServiceProvider = options.BuildServiceProvider();

            _logger             = ServiceProvider.GetRequiredService <ILogger <ClusterContext> >();
            _redactor           = ServiceProvider.GetRequiredService <IRedactor>();
            _configHandler      = ServiceProvider.GetRequiredService <IConfigHandler>();
            _clusterNodeFactory = ServiceProvider.GetRequiredService <IClusterNodeFactory>();
        }
Beispiel #18
0
        public VoiceCommandHandler( IConfigHandler config, ITimerHandler timerHandler )
        {
            this.engine = new SpeechRecognitionEngine();
            this.timerHandler = timerHandler;

            var builder = new GrammarBuilder();
            builder.Append( new Choices( config.Config.Verbs.ToArray() ) );
            builder.Append( new Choices( config.Commands.ToArray() ) );

            this.engine.RequestRecognizerUpdate();
            this.engine.LoadGrammar( new Grammar( builder ) );

            this.engine.SpeechRecognized += engine_SpeechRecognized;

            this.engine.SetInputToDefaultAudioDevice();
            this.engine.RecognizeAsync( RecognizeMode.Multiple );
        }
        internal void Execute(IConsole console, IConfigHandler configHandler, IFileSystem fileSystem, ILinker linker, IPathResolver pathResolver)
        {
            if (!configHandler.DoesConfigExist(path))
            {
                console.WriteLine($"Config '{ path }' does not exist. Type 'help config' in order to see how you create a config file.", IConsole.ContentType.Negative);
                return;
            }

            IConfig config = configHandler.LoadConfig(path);

            console.WriteLine("\nCreating links based on config...");

            int successes = 0;

            // Allow linkers verbose output if flag is set for this command
            linker.verbose = verbose;

            foreach (ConfigLink configLink in config.LinkList)
            {
                string resolvedSourcePath = pathResolver.GetAbsoluteResolvedPath(configLink.sourcePath, config.Variables);
                string resolvedTargetPath = pathResolver.GetAbsoluteResolvedPath(configLink.targetPath, config.Variables);

                CreateSubDirectories(console, fileSystem, pathResolver, config, resolvedTargetPath);

                if (fileSystem.Directory.Exists(resolvedTargetPath) || fileSystem.File.Exists(resolvedTargetPath))
                {
                    console.Write($"Path '{configLink.targetPath}' already exists", IConsole.ContentType.Negative);

                    if (verbose)
                    {
                        console.Write($" (resolved to '{resolvedTargetPath}')", IConsole.ContentType.Negative);
                    }

                    console.WriteLine();
                }
                else if (linker.CreateLink(resolvedSourcePath, resolvedTargetPath, configLink.linkType))
                {
                    successes++;
                }
            }

            console.WriteLine("\n### Finished! Created {0} / {1} links ###", successes, config.LinkList.Count);
        }
        internal void Execute(IConsole console, IConfigHandler configHandler, IFileSystem fileSystem, IPathResolver pathResolver)
        {
            if (!configHandler.DoesConfigExist(path))
            {
                console.WriteLine($"Config '{ path }' does not exist. Type 'help config' in order to see how you create a config file.", IConsole.ContentType.Negative);
                return;
            }

            IConfig config = configHandler.LoadConfig(path);

            if (!displayVariables)
            {
                foreach (ConfigLink configLink in config.LinkList)
                {
                    string absoluteSourcePathString = "";
                    string absoluteTargetPathString = "";

                    if (displayAbsolutePaths)
                    {
                        absoluteSourcePathString = $"\n\t\t  => { pathResolver.GetAbsoluteResolvedPath(configLink.sourcePath, config.Variables) }";
                        absoluteTargetPathString = $"\n\t\t  => { pathResolver.GetAbsoluteResolvedPath(configLink.targetPath, config.Variables) }";
                    }

                    console.WriteLine($"\n" +
                                      $"{ configLink.linkType.ToString() } link:\n" +
                                      $"\t- Source: { configLink.sourcePath }{ absoluteSourcePathString }\n" +
                                      $"\t- Target: { configLink.targetPath }{ absoluteTargetPathString }\n");
                }
            }
            else
            {
                foreach (Variable variable in config.Variables)
                {
                    console.WriteLine($"\n { variable.ToString() }");
                }
            }

            if (config.LinkList.Count == 0)
            {
                console.WriteLine("Config is empty");
            }
        }
Beispiel #21
0
        public SettingsViewModel(
            IWindowService windowService,
            IConfigHandler configHandler,
            IFavoritesService favoritesService,
            IStatusSetter statusSetter,
            IHueService hueService)
        {
            this.windowService    = windowService;
            this.favoritesService = favoritesService;
            this.statusSetter     = statusSetter;
            this.hueService       = hueService;
            config = configHandler.LoadFromFile();

            StartSkypeAndSteamCommand = new RelayCommand(OnStartSkypeAndSteamCommand);
            EditFavoritesCommand      = new RelayCommand(OnEditFavoritesCommand);
            RegisterHueCommand        = new RelayCommand(OnRegisterHueCommand);
            AboutCommand          = new RelayCommand(OnAboutCommand);
            ClearFavoritesCommand = new RelayCommand(OnClearFavoritesCommand);
            ExitProgramCommand    = new RelayCommand(OnExitProgramCommand);
        }
        internal void Execute(IConsole console, IConfigHandler configHandler, IFileSystem fileSystem, IPathResolver pathResolver)
        {
            if (!configHandler.DoesConfigExist(path))
            {
                console.WriteLine($"Config '{ path }' does not exist. Type 'help config' in order to see how you create a config file.", IConsole.ContentType.Negative);
                return;
            }

            IConfig    config     = configHandler.LoadConfig(path);
            ConfigLink configLink = config.LinkList.FirstOrDefault(link => pathResolver.GetAbsoluteResolvedPath(link.targetPath, config.Variables).Equals(pathResolver.GetAbsoluteResolvedPath(targetPath, config.Variables)));

            if (configLink != null)
            {
                config.LinkList.Remove(configLink);
                console.WriteLine("\nSuccessfully removed link with targetPath '{0}'", targetPath);

                configHandler.SaveConfig(config, path);
            }
            else
            {
                console.WriteLine($"\nThe targetPath '{targetPath}' is invalid because it does not exist in config", IConsole.ContentType.Negative);
            }
        }
Beispiel #23
0
        public void Execute(IConsole console, IConfigHandler configHandler, IFileSystem fileSystem)
        {
            if (!configHandler.DoesConfigExist(path))
            {
                console.WriteLine($"Config '{ path }' does not exist. Type 'help config' in order to see how you create a config file.", IConsole.ContentType.Negative);
                return;
            }

            IConfig  config           = configHandler.LoadConfig(path);
            Variable existingVariable = config.Variables.FirstOrDefault(variable => variable.name.Equals(name, StringComparison.OrdinalIgnoreCase));

            if (existingVariable == null)
            {
                console.WriteLine($"A variable with name '{ name }' does not exist", IConsole.ContentType.Negative);
            }
            else
            {
                config.Variables.Remove(existingVariable);
                configHandler.SaveConfig(config, path);

                console.WriteLine($"Variable with name '{ name }' has been removed");
            }
        }
Beispiel #24
0
        public YoutubeService(IConfigHandler configHandler)
        {
            this.configHandler = configHandler;
            var config = configHandler.Config;

            clientId      = config.YoutubeClientId;
            clientSecret  = config.YoutubeClientSecret;
            youtubeApiKey = config.YoutubeApiKey;
            channelId     = config.YoutubeChannelId;

            state          = RandomDataBase64url(32);
            code_verifier  = RandomDataBase64url(32);
            code_challenge = Base64urlencodeNoPadding(Sha256(code_verifier));

            string youtubeAuthScope = "https://www.googleapis.com/auth/youtube.readonly";

            OAuthUrl = $"{authorizationEndpoint}?response_type=code&scope={youtubeAuthScope}&redirect_uri=" +
                       $"{redirectUrl}&client_id={clientId}&state={state}&code_challenge={code_challenge}" +
                       $"&code_challenge_method={code_challenge_method}";

            var baseUrl = "https://www.googleapis.com/";

            client = new RestClient(baseUrl);
        }
Beispiel #25
0
        internal void Execute(IConsole console, IConfigHandler configHandler, IFileSystem fileSystem, IPathResolver pathResolver)
        {
            if (!configHandler.DoesConfigExist(path))
            {
                console.WriteLine($"Config '{ path }' does not exist. Type 'help config' in order to see how you create a config file.", IConsole.ContentType.Negative);
                return;
            }

            IConfig config = configHandler.LoadConfig(path);

            // Force forward slash
            sourcePath = sourcePath.Replace('\\', '/');
            targetPath = targetPath.Replace('\\', '/');

            string formattedSourcePath = pathResolver.GetAbsoluteResolvedPath(sourcePath, config.Variables);
            string formattedTargetPath = pathResolver.GetAbsoluteResolvedPath(targetPath, config.Variables);

            if (!force && !fileSystem.File.Exists(formattedSourcePath) && !fileSystem.Directory.Exists(formattedSourcePath))
            {
                console.WriteLine($"\nThe sourcePath '{sourcePath}' is invalid because it does not exist", IConsole.ContentType.Negative);
                return;
            }

            if (!force && config.LinkList.Any(link => pathResolver.GetAbsoluteResolvedPath(link.targetPath, config.Variables).Equals(formattedTargetPath)))
            {
                console.WriteLine($"\nThe targetPath '{targetPath}' is invalid because it already exists in config file", IConsole.ContentType.Negative);
                return;
            }

            config.LinkList.Add(new ConfigLink(sourcePath, targetPath, linkType));
            configHandler.SaveConfig(config, path);

            console.WriteLine($"\nAdded new { linkType.ToString() } link to config file: \n" +
                              $"Source: '{ sourcePath }'\n" +
                              $"Target: '{ targetPath }'");
        }
Beispiel #26
0
        internal void TryCreateLink(IConsole console, IConfigHandler configHandler, IFileSystem fileSystem, IPathResolver pathResolver, IConfig config, string sourcePath, string targetBasePath, bool isFile)
        {
            try {
                // Check absolute path regex filter first
                if (Regex.IsMatch(pathResolver.GetAbsoluteResolvedPath(sourcePath, config.Variables), absoluteRegexFilter))
                {
                    string fileOrDirectoryName = fileSystem.Path.GetFileName(sourcePath);

                    // Check file / directory name regex filter second
                    if (Regex.IsMatch(fileOrDirectoryName, regexFilter))
                    {
                        AddLinkCommand addLinkCommand = new AddLinkCommand(
                            sourcePath,
                            fileSystem.Path.Combine(targetBasePath, fileOrDirectoryName),
                            linkType,
                            path);

                        addLinkCommand.Execute(console, configHandler, fileSystem, pathResolver);
                    }
                }
            } catch (ArgumentException) {
                console.WriteLine("Regex provided is invalid!", IConsole.ContentType.Negative);
            }
        }
Beispiel #27
0
 internal static extern void RunParser(IConfigHandler factory, String fileName);
Beispiel #28
0
 public HttpStreamingConfigListener Create(IBucket bucket, IConfigHandler configHandler) =>
 new HttpStreamingConfigListener(bucket, _clusterOptions,
                                 _serviceProvider.GetRequiredService <ICouchbaseHttpClientFactory>(), // Get each time so it's not a singleton
                                 configHandler, _logger);
Beispiel #29
0
 public LoginHandler(ILogger <LoginHandler> logger, IConfigHandler configHandler)
 {
     _logger        = logger;
     _configHandler = configHandler;
 }
 internal static extern void RunParser(IConfigHandler factory, String fileName);
 public CreateJsonFile(IFileHandler fileHandler, IConfigHandler configHandler)
 {
     _fileHandler   = fileHandler;
     _configHandler = configHandler;
 }
Beispiel #32
0
 public ConfigController(IConfigHandler configHandler)
 {
     _configHandler = configHandler;
 }
Beispiel #33
0
        private void InitConfig()
        {
            AddLog("Loading configuration values...");

            // _configHandler = new AppConfigHandler();
            _configHandler = new JsonConfigHandler();
            var config = _configHandler.GetConfig();
            _ipChecker = new AwsIpChecker();
            IAmazonRoute53 _amazonClient = new AmazonRoute53Client(config.Route53AccessKey, config.Route53SecretKey, RegionEndpoint.EUWest1);
            _dnsUpdater = new DnsUpdater(_configHandler, _ipChecker, _amazonClient);

            AddLog($"Found {config.DomainList.Count} domain(s)");
            foreach (HostedDomainInfo domainInfo in config.DomainList)
            {
                AddLog($"{domainInfo.DomainName}");
            }

            if (_timer != null)
            {
                // Stop to avoid multiple timer_Tick invocations
                _timer.Stop();
            }

            int interval = config.UpdateInterval;
            _timer = new System.Windows.Threading.DispatcherTimer();
            _timer.Tick += timer_Tick;
            _timer.Interval = new TimeSpan(0, interval, 0);
            _timer.Start();

            AddLog($"Time set to update domains every {interval} minutes");

            SetAutoStart();
        }
Beispiel #34
0
        internal void Execute(IConsole console, IConfigHandler configHandler, IFileSystem fileSystem, IPathResolver pathResolver)
        {
            if (!configHandler.DoesConfigExist(path))
            {
                console.WriteLine($"Config '{ path }' does not exist. Type 'help config' in order to see how you create a config file.", IConsole.ContentType.Negative);
                return;
            }

            IConfig config  = configHandler.LoadConfig(path);
            bool    isValid = true;

            foreach (ConfigLink configLink in config.LinkList)
            {
                string resolvedSourcePath = pathResolver.GetAbsoluteResolvedPath(configLink.sourcePath, config.Variables);
                string resolvedTargetPath = pathResolver.GetAbsoluteResolvedPath(configLink.targetPath, config.Variables);

                bool validation1 = ValidateExistence(fileSystem, resolvedSourcePath);
                bool validation2 = ValidateLinkType(fileSystem, resolvedSourcePath, configLink.linkType);
                bool validation3 = ValidateDuplicate(pathResolver, config, resolvedTargetPath);

                if (displayAll || !validation1 || !validation2 || !validation3)
                {
                    console.WriteLine($"\n{ configLink.ToString() }");

                    isValid = false;
                }

                if (!validation1 || displayAll)
                {
                    console.WriteLine($"\t# Source path exists: { (validation1 ? "Yes" : "No") }",
                                      validation1
                        ? IConsole.ContentType.Positive
                        : IConsole.ContentType.Negative);
                }

                if (!validation2 || displayAll)
                {
                    console.WriteLine($"\t# Link type acceptable: { (validation2 ? "Yes" : "No") }",
                                      validation2
                        ? IConsole.ContentType.Positive
                        : IConsole.ContentType.Negative);
                }

                if (!validation3 || displayAll)
                {
                    console.WriteLine($"\t# Duplicate target path exists: { (validation3 ? "False" : "True") }",
                                      validation3
                        ? IConsole.ContentType.Positive
                        : IConsole.ContentType.Negative);
                }
            }

            if (config.LinkList.Count == 0)
            {
                console.WriteLine("Config is empty");
            }
            else if (isValid)
            {
                console.WriteLine("Config is 100% valid");
            }
        }
Beispiel #35
0
 public Publisher(IConfigHandler configHandler)
 {
     _configHandler = configHandler;
     InitializeComponent();
 }