public void Setup()
 {
     var connectionTreeModel = SetupConnectionTreeModel();
     var cryptoProvider = new CryptographyProviderFactory().CreateAeadCryptographyProvider(BlockCipherEngines.AES, BlockCipherModes.GCM);
     _originalDocument = new XmlConnectionsDocumentCompiler(cryptoProvider).CompileDocument(connectionTreeModel, false, false);
     _documentEncryptor = new XmlConnectionsDocumentEncryptor(cryptoProvider);
 }
        public XDocument CompileDocument(ConnectionInfo serializationTarget, bool fullFileEncryption, bool export)
        {
            var rootNodeInfo = GetRootNodeFromConnectionInfo(serializationTarget);
            _encryptionKey = rootNodeInfo.PasswordString.ConvertToSecureString();
            var rootElement = CompileRootNode(rootNodeInfo, fullFileEncryption, export);

            CompileRecursive(serializationTarget, rootElement);
            var xmlDeclaration = new XDeclaration("1.0", "utf-8", null);
            var xmlDocument = new XDocument(xmlDeclaration, rootElement);
            if (fullFileEncryption)
                xmlDocument = new XmlConnectionsDocumentEncryptor(_cryptographyProvider).EncryptDocument(xmlDocument, _encryptionKey);
            return xmlDocument;
        }
        public XDocument CompileDocument(ConnectionInfo serializationTarget, bool fullFileEncryption, bool export)
        {
            var rootNodeInfo = GetRootNodeFromConnectionInfo(serializationTarget);

            _encryptionKey = rootNodeInfo.PasswordString.ConvertToSecureString();
            var rootElement = CompileRootNode(rootNodeInfo, fullFileEncryption, export);

            CompileRecursive(serializationTarget, rootElement);
            var xmlDeclaration = new XDeclaration("1.0", "utf-8", null);
            var xmlDocument    = new XDocument(xmlDeclaration, rootElement);

            if (fullFileEncryption)
            {
                xmlDocument = new XmlConnectionsDocumentEncryptor(_cryptographyProvider).EncryptDocument(xmlDocument, _encryptionKey);
            }
            return(xmlDocument);
        }