public ConnectionTreeModel LoadConnections(bool import) { IDeserializer deserializer; if (UseDatabase) { var connector = new SqlDatabaseConnector(); var dataProvider = new SqlDataProvider(connector); var dataTable = dataProvider.Load(); deserializer = new DataTableDeserializer(dataTable); } else { var dataProvider = new FileDataProvider(ConnectionFileName); var xmlString = dataProvider.Load(); deserializer = new XmlConnectionsDeserializer(xmlString, PromptForPassword); } var connectionTreeModel = deserializer.Deserialize(); if (connectionTreeModel != null) frmMain.Default.ConnectionsFileName = ConnectionFileName; else connectionTreeModel = new ConnectionTreeModel(); if (import) return connectionTreeModel; PuttySessionsManager.Instance.AddSessions(); connectionTreeModel.RootNodes.AddRange(PuttySessionsManager.Instance.RootPuttySessionsNodes); return connectionTreeModel; }
public void SerializeAndDeserializePropertiesWithInternationalCharacters() { var originalConnectionInfo = new ConnectionInfo {Name = "con1", Password = "******" }; var serializedContent = _serializer.Serialize(originalConnectionInfo); _deserializer = new XmlConnectionsDeserializer(serializedContent); var deserializedModel = _deserializer.Deserialize(); var deserializedConnectionInfo = deserializedModel.GetRecursiveChildList().First(node => node.Name == originalConnectionInfo.Name); Assert.That(deserializedConnectionInfo.Password, Is.EqualTo(originalConnectionInfo.Password)); }
public void SerializeThenDeserialize() { var originalModel = SetupConnectionTreeModel(); var serializedContent = _serializer.Serialize(originalModel); _deserializer = new XmlConnectionsDeserializer(serializedContent); var deserializedModel = _deserializer.Deserialize(); var nodeNamesFromDeserializedModel = deserializedModel.GetRecursiveChildList().Select(node => node.Name); var nodeNamesFromOriginalModel = originalModel.GetRecursiveChildList().Select(node => node.Name); Assert.That(nodeNamesFromDeserializedModel, Is.EquivalentTo(nodeNamesFromOriginalModel)); }
public void Import(string fileName, ContainerInfo destinationContainer) { var dataProvider = new FileDataProvider(fileName); var xmlString = dataProvider.Load(); var xmlConnectionsDeserializer = new XmlConnectionsDeserializer(xmlString); var connectionTreeModel = xmlConnectionsDeserializer.Deserialize(true); var rootImportContainer = new ContainerInfo { Name = Path.GetFileNameWithoutExtension(fileName) }; rootImportContainer.Children.AddRange(connectionTreeModel.RootNodes.First().Children); destinationContainer.AddChild(rootImportContainer); }
public void SerializeAndDeserializeWithCustomKdfIterationsValue() { var cryptoProvider = new CryptographyProviderFactory().CreateAeadCryptographyProvider(BlockCipherEngines.AES, BlockCipherModes.GCM); cryptoProvider.KeyDerivationIterations = 5000; _serializer = new XmlConnectionsSerializer(cryptoProvider); var originalModel = SetupConnectionTreeModel(); var serializedContent = _serializer.Serialize(originalModel); _deserializer = new XmlConnectionsDeserializer(serializedContent); var deserializedModel = _deserializer.Deserialize(); var nodeNamesFromDeserializedModel = deserializedModel.GetRecursiveChildList().Select(node => node.Name); var nodeNamesFromOriginalModel = originalModel.GetRecursiveChildList().Select(node => node.Name); Assert.That(nodeNamesFromDeserializedModel, Is.EquivalentTo(nodeNamesFromOriginalModel)); }
public void Teardown() { _serializer = null; _deserializer = null; }
public void Teardown() { _xmlConnectionsDeserializer = null; _connectionTreeModel = null; }
public void Setup(string confCons, string password) { _xmlConnectionsDeserializer = new XmlConnectionsDeserializer(confCons, password.ConvertToSecureString); _connectionTreeModel = _xmlConnectionsDeserializer.Deserialize(); }