public void CreateConfigFile()
 {
     var config = new FileConfig();
     config.DeCorrespondentUsername = "******";
     config.DeCorrespondentPassword = Encryptor.EncryptAES("password");
     config.EvoPdfLicenseKey = "lickey";
     config.MaxAantalArticles = 20;
     config.KindleEmail = "t";
     config.SmtpUsername = "******";
     config.SmtpPassword = Encryptor.EncryptAES(@"password");
     config.Save("d:\\config.xml");
 }
 private static Program Instance(ProgramArguments args, ILogger logger, IDeCorrespondentResources decorrespondent, FileConfig config)
 {
     var reader = new ArticleReader();
     var renderer = string.IsNullOrEmpty(config.EvoPdfLicenseKey)
         ? new HtmlArticleRenderer(logger, config.ArticleRendererConfig)
         : new PdfArticleRenderer(logger, config.ArticleRendererConfig, config.EvoPdfLicenseKey) as IArticleRenderer;
     var lastIdDs = new FileLastDatasource();
     var mailer = new SmtpMailer(logger, config.SmtpMailConfig);
     var kindle = new KindleEmailSender(logger, config.KindleEmailSenderConfig, mailer);
     var summarySender = new EmailNotificationSender(logger, mailer, config.EmailNotificationSenderConfig);
     return new Program(args, logger, reader, renderer, decorrespondent, lastIdDs, kindle, summarySender, config.MaxAantalArticles);
 }
 private static ProgramArguments HandleArguments(string[] args, FileConfig config)
 {
     if (args.Length == 0)
         return new ProgramArguments(true);
     if (args.Length > 0 && args[0] == "/config")
     {
         typeof (FileConfig).GetProperties()
             .Where(p => p.GetCustomAttributes(typeof (FileConfig.ConfigurableViaCommandLine), true).Any())
             .Select(p => new
             {
                 Property = p,
                 Attribute = p.GetCustomAttributes(typeof (FileConfig.ConfigurableViaCommandLine), true).OfType<FileConfig.ConfigurableViaCommandLine>().First(),
                 Value = p.GetGetMethod().Invoke(config, new object[0]) as string
             })
             .Select(x => new { x.Property, x.Attribute, x.Value, IsEncrypted = x.Attribute.IsPassword })
             .ToList()
             .ForEach(x =>
             {
                 Console.WriteLine("{0}:\n [enter]='{1}'", x.Attribute.Description, x.Attribute.Display(x.Value));
                 var newValue = Console.ReadLine();
                 if (!string.IsNullOrEmpty(newValue))
                     x.Property.GetSetMethod().Invoke(config, new object[] { x.IsEncrypted ? Encryptor.EncryptAES(newValue) : newValue });
             });
         config.Save(null);
         Console.WriteLine("Configuratie opgeslagen.");
         return new ProgramArguments(false);
     }
     else if (args.Length > 0 && args[0].StartsWith("/id="))
     {
         var result = new ProgramArguments(true);
         result.ArticleId = int.Parse(args[0].Split('=')[1]);
         return result;
     }
     else if (args.Length > 0 && args[0].StartsWith("/i"))
     {
         var result = new ProgramArguments(true);
         result.RunInteractiveMode = true;
         return result;
     }
     else
     {
         Console.WriteLine("/config : Pas de configuratie aan (config.xml)");
         Console.WriteLine("/id={articleId} : Run voor 1 specifiek artikel (id)");
         Console.WriteLine("/i : Interactieve modus: vraag welke artikelen te versturen");
         return new ProgramArguments(false);
     }
 }
 private static string SerializeXml(FileConfig model)
 {
     var serializer = new XmlSerializer(typeof(FileConfig));
     var sb = new StringBuilder(2048);
     serializer.Serialize(new StringWriter(sb), model);
     return sb.ToString();
 }