FubarDev.FtpServer.FtpConnection.FtpConnection C# (CSharp) Method

FtpConnection() public method

Initializes a new instance of the FtpConnection class.
public FtpConnection ( [ server, [ socket, [ encoding ) : System
server [ The server this connection belongs to
socket [ The socket to use to communicate with the client
encoding [ The encoding to use for the LIST/NLST commands
return System
        public FtpConnection([NotNull] FtpServer server, [NotNull] ITcpSocketClient socket, [NotNull] Encoding encoding)
        {
            Server = server;
            _socket = socket;
            RemoteAddress = new Address(socket.RemoteAddress, socket.RemotePort);
            SocketStream = OriginalStream = socket.GetStream();
            Encoding = encoding;
            Data = new FtpConnectionData(this);
            var commandHandlers = Server.CommandsHandlerFactory.CreateCommandHandlers(this).ToList();
            CommandHandlers = commandHandlers
                .SelectMany(x => x.Names, (item, name) => new { Name = name, Item = item })
                .ToDictionary(x => x.Name, x => x.Item, StringComparer.OrdinalIgnoreCase);

            // Add stand-alone extensions
            AddExtensions(Server.CommandsHandlerFactory.CreateCommandHandlerExtensions(this));

            // Add extensions provided by command handlers
            foreach (var commandHandler in commandHandlers)
                AddExtensions(commandHandler.GetExtensions());
        }