public void Export(ExportOptions options) { try { using (var w = new XmlTextWriter(options.FileName, Encoding.UTF8)) { w.Formatting = Formatting.Indented; w.WriteStartDocument(); w.WriteStartElement("favorites"); foreach (FavoriteConfigurationElement favorite in options.Favorites) { var favoriteSecurity = new FavoriteConfigurationSecurity(this.persistence, favorite); var context = new ExportOptionsContext(w, favoriteSecurity, options.IncludePasswords, favorite); WriteFavorite(context); } w.WriteEndElement(); w.WriteEndDocument(); w.Flush(); w.Close(); } } catch (Exception ex) { Logging.Error("Export XML Failed", ex); } }
private void ExportCredentials(ExportOptionsContext context) { FavoriteConfigurationElement favorite = context.Favorite; var favoriteSecurity = new FavoriteConfigurationSecurity(this.persistence, favorite); context.WriteElementString("credential", favorite.Credential); context.WriteElementString("domainName", favoriteSecurity.ResolveDomainName()); if (context.IncludePasswords) { context.WriteElementString("userName", favoriteSecurity.ResolveUserName()); context.WriteElementString("password", favoriteSecurity.Password); } }
private void WriteFavorite(ExportOptionsContext context) { context.Writer.WriteStartElement("favorite"); ExportGeneralOptions(context.Writer, context.Favorite); ExportCredentials(context); ExportExecuteBeforeConnect(context.Writer, context.Favorite); foreach (ITerminalsOptionsExport optionsExporter in this.optionsExporters) { optionsExporter.ExportOptions(context); } context.Writer.WriteEndElement(); }