Esempio n. 1
0
 public static ChannelDirection Get(ChannelSettings channelSettings)
 {
     if (channelSettings.GetType().Name == typeof(FromSettings).Name)
     {
         return(ChannelDirection.Inbound);
     }
     else if (channelSettings.GetType().Name == typeof(ToSettings).Name)
     {
         return(ChannelDirection.Outbound);
     }
     throw new InvalidCastException($"Invalid channel direction {channelSettings.GetType().Name}");
 }
        public static IChannel Create(ChannelSettings channelSettings, DirectoryInfo workingDirectory)
        {
            if (channelSettings == null)
            {
                throw new ArgumentNullException(nameof(channelSettings));
            }

            if (workingDirectory == null)
            {
                throw new ArgumentNullException(nameof(workingDirectory));
            }

            ChannelDirection channelDirection = channelSettings.GetType() == typeof(FromSettings) ? ChannelDirection.Inbound : ChannelDirection.Outbound;

            switch (channelSettings.Type)
            {
            case ConfigChannelType.Local:
            {
                return(new LocalChannel(workingDirectory, channelSettings));
            }

            case ConfigChannelType.Sftp:
            {
                return(new SftpChannel(workingDirectory, channelSettings));
            }

            default:
            {
                throw new InvalidOperationException($"There is no corresponding channel type for '{channelSettings.Type}'.");
            }
            }
        }