private void TryInitializeConfigFile() { if (ConfigFilename == null) { return; } // CR (krait): Для этого написан экстеншн, но почему-то не используется. try { FileExtensions.TryGetReadAccess(ConfigFilename); } catch (Exception exception) { throw new ArgumentException($"Can't read config file {ConfigFilename}", exception); } try { var deserializer = new DeserializerBuilder() .WithNamingConvention(new UnderscoredNamingConvention()).Build(); // CR (krait): А стрим кто будет закрывать? var options = deserializer.Deserialize <CliOptions>(new StreamReader(File.OpenRead(ConfigFilename))); InputFilename = InputFilename ?? options.InputFilename; OutputFilename = OutputFilename ?? options.OutputFilename; BaseUrl = BaseUrl ?? options.BaseUrl; HtmlFilename = HtmlFilename ?? options.HtmlFilename; InjectedHtmlElement = InjectedHtmlElement ?? options.InjectedHtmlElement; InjectCssClass = InjectCssClass ?? options.InjectCssClass; } catch (Exception exception) { throw new YamlException($"Exception during parseing YAML configuartion file {ConfigFilename}", exception); } }
private void TryInitializeInputFile() { try { FileExtensions.TryGetReadAccess(InputFilename); } catch (Exception exception) { throw new ArgumentException($"Can't read from input file {InputFilename}", exception); } }
private void TryInitializeHtmlFile() { if (HtmlFilename != null) { if (InjectedHtmlElement == null) { throw new ArgumentException( "InjectedField must be specified if used HtmlFilename. It can be specified with --inject_el option" ); } try { FileExtensions.TryGetReadAccess(HtmlFilename); } catch (Exception exception) { throw new ArgumentException($"Can't read from html file {HtmlFilename}", exception); } } }