mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-25 19:38:37 +08:00
27 lines
917 B
C#
27 lines
917 B
C#
using System.IO;
|
|
using System.Linq;
|
|
using mRemoteNG.Config.DataProviders;
|
|
using mRemoteNG.Config.Serializers;
|
|
using mRemoteNG.Container;
|
|
|
|
|
|
namespace mRemoteNG.Config.Import
|
|
{
|
|
public class RemoteDesktopConnectionImporter : IConnectionImporter<string>
|
|
{
|
|
public void Import(string fileName, ContainerInfo destinationContainer)
|
|
{
|
|
var dataProvider = new FileDataProvider(fileName);
|
|
var content = dataProvider.Load();
|
|
|
|
var deserializer = new RemoteDesktopConnectionDeserializer();
|
|
var connectionTreeModel = deserializer.Deserialize(content);
|
|
|
|
var importedConnection = connectionTreeModel.RootNodes.First().Children.First();
|
|
|
|
if (importedConnection == null) return;
|
|
importedConnection.Name = Path.GetFileNameWithoutExtension(fileName);
|
|
destinationContainer.AddChild(importedConnection);
|
|
}
|
|
}
|
|
} |